Skip to main content

Install And Setup Android Emulator Ubuntu

Requirement

If you have not installed Android Studio, proceed to [Setup Android Studio]

Getting Started

Option 1 - Launch Emulator from Android Studio

  1. Launch Android Studio
  2. Under Tools Menu, select Device Manager
  3. At Device Manager, you will see default device, and you can launch it

Option 2 - Launch Emulator from command line

  1. Create one symbolic link emulator
# for mac
$ ln -s ~/Library/Android/sdk/tools/emulator /usr/local/bin/emulator

# for ubuntu
$ ln -s ~/Android/Sdk/tools/emulator /usr/local/bin/emulator
# for x86
$ ln -s ~/Android/Sdk/tools/emulator-x86 /usr/local/bin/emulator-x86
  1. Add below lines to .zshrc file
# Android
export ANDROID_HOME=~/Android/Sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
  1. Update config
source ~/.zshrc
  1. Test command
emulator -list-avds
$ Output
$ Pixel_3a_API_31.avd
  1. Launch Emulator
cd ~/Android/Sdk/emulator
emulator -avd Pixel_3a_API_31 -netdelay none -netspeed full -feature -Vulkan;

Google Play Services

Option 1 - Setup Device from Android Studio

During device setup, search for image with google play icon

Device-with-google-play

tip

If you have setup Device from Android studio, you don't need to amend config file

From Android studio just need to configure your device correctly

  1. Create a new emulator, and before opening it for the first time, follow these easy steps:

  2. Locate the directory where the emulator has been created.

  • In Windows go to: %userprofile%.android\avd and open your virtual device folder.

  • In Ubuntu go to : ~/.android/avd

  1. Open file config.ini with a text editor

  2. Locate PlayStore.enabled key and change its value to true:

PlayStore.enabled = true
  1. Locate image.sysdir.1 key and change to google_apis_playstore

Example:

image.sysdir.1=system-images/android-33/google_apis/x86_64/

to

image.sysdir.1=system-images/android-33/google_apis_playstore/x86_64/

Config.ini

Option 2 - Install Google Play Services on Android Studio Emulator via OpenGApps

  1. Download a Open GApps zip file from the site. http://opengapps.org/ As of documenting, the downloaded zip is: open_gapps-x86-11.0-pico-20220503.zip

  2. Extract packages.

unzip open_gapps-x86-11.0-pico-20220503.zip 'Core/*'
rm Core/setup*
lzip -d Core/*.lz
for f in $(ls Core/*.tar); do
tar -x --strip-components 2 -f $f
done
  1. Start an emulator.
cd ~/Android/Sdk/emulator
emulator -avd Pixel_3a_API_31 -writable-system &
  1. Install packages.
ANDROID_HOME/platform-tools/adb remount
ANDROID_HOME/platform-tools/adb push etc /system
ANDROID_HOME/platform-tools/adb push framework /system
ANDROID_HOME/platform-tools/adb push app /system
ANDROID_HOME/platform-tools/adb push priv-app /system
  1. Restart.
ANDROID_HOME/platform-tools/adb shell stop
ANDROID_HOME/platform-tools/adb shell start

Kill emulator

Print a list of your devices:

adb devices

Kill it using emu

adb -s emulator-5432 emu kill

Troubleshoot

Cannot open webpage correctly

Starting with API level 30, Chrome uses the Vulkan graphics library as its rendering backend, and it could have compatibility issues on certain machines. If Chrome does not render correctly for you, try to launch the emulator from the command line with the flag -feature -Vulkan.

emulator -avd avd_name [ {-option [value]}]

Example:

emulator -avd Pixel_3a_API_31 -netdelay none -netspeed full -feature -Vulkan;