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
- Launch Android Studio
- Under Tools Menu, select Device Manager
- At Device Manager, you will see default device, and you can launch it
Option 2 - Launch Emulator from command line
- 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
- 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
- Update config
source ~/.zshrc
- Test command
emulator -list-avds
$ Output
$ Pixel_3a_API_31.avd
- 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
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
Create a new emulator, and before opening it for the first time, follow these easy steps:
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
Open file config.ini with a text editor
Locate PlayStore.enabled key and change its value to true:
PlayStore.enabled = true
- 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/
Option 2 - Install Google Play Services on Android Studio Emulator via OpenGApps
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
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
- Start an emulator.
cd ~/Android/Sdk/emulator
emulator -avd Pixel_3a_API_31 -writable-system &
- 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
- 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;