Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing and running Android Emulator on Amazon AWS EC2 (Ubuntu 16.04 / m5.xlarge)
Steps for installing the Android Emulator from EC2 console:
-----------------------------------------------------------
sudo apt install default-jdk
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d android-sdk
sudo mv android-sdk /opt/
export ANDROID_SDK_ROOT=/opt/android-sdk
echo "export ANDROID_SDK_ROOT=/opt/android-sdk" >> ~/.bashrc
echo "export PATH=$PATH:$ANDROID_SDK_ROOT/tools" >> ~/.bashrc
re-login
cd /opt/android-sdk/tools/bin
/opt/android-sdk/tools/bin/sdkmanager --update
/opt/android-sdk/tools/bin/sdkmanager --licenses
/opt/android-sdk/tools/bin/sdkmanager "system-images;android-25;google_apis;armeabi-v7a"
/opt/android-sdk/tools/bin/sdkmanager "emulator"
/opt/android-sdk/tools/bin/sdkmanager "platform-tools"
touch /home/ubuntu/.android/repositories.cfg
mkdir /opt/android-sdk/platforms
/opt/android-sdk/tools/bin/avdmanager -v create avd -f -n MyAVD -k "system-images;android-25;google_apis;armeabi-v7a" -p "/opt/android-sdk/avd"
Optional: eanbling/disabling certain HW features
-------------------------------------------------
echo "hw.audioInput=no" >> /opt/android-sdk/avd/config.ini
echo "hw.audioOutput=no" >> /opt/android-sdk/avd/config.ini
echo "hw.cpu.ncore=2" >> /opt/android-sdk/avd/config.ini
echo "hw.camera.back=none" >> /opt/android-sdk/avd/config.ini
echo "hw.camera.front=none" >> /opt/android-sdk/avd/config.ini
echo "hw.gsmModem=no" >> /opt/android-sdk/avd/config.ini
echo "hw.gps=no" >> /opt/android-sdk/avd/config.ini
echo "hw.accelerometer=no" >> /opt/android-sdk/avd/config.ini
echo "hw.battery=no" >> /opt/android-sdk/avd/config.ini
echo "hw.trackBall=no" >> /opt/android-sdk/avd/config.ini
echo "hw.dPad=no" >> /opt/android-sdk/avd/config.ini
echo "hw.sensors.proximity=no" >> /opt/android-sdk/avd/config.ini
echo "hw.sensors.magnetic_field=no" >> /opt/android-sdk/avd/config.ini
echo "hw.sensors.orientation=no" >> /opt/android-sdk/avd/config.ini
echo "hw.sensors.temperature=no" >> /opt/android-sdk/avd/config.ini
Running the Emulator:
---------------------
/opt/android-sdk/emulator/emulator -ports 5554,5555 -avd MyAVD -no-window -no-audio -gpu swiftshader_indirect -show-kernel
Fixing 100% CPU: Disabling the "Ok Google" Hotword detection:
-------------------------------------------------------------
./adb shell "su root pm disable com.google.android.googlequicksearchbox"
Note: run after Emulator loaded
Notes:
------
1. We run ARM emulation on x86 instance.
2. We must use ARM ABI, since x86 requires KVM and EC2 instance doesn't support HW virtualization.
3. We must disable GUI (-no-window) and audio (-no-audio) when running the emulator.
4. We must specify "-gpu swiftshader_indirect" when running the emulator to prevent a boot loop.
5. First startup takes VERY LONG time. Use "-show-kernel" to see kernel messages and in secondary console window use "/opt/android-sdk/platform-tools/adb logcat" to see the system log while the emulator starts.
@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented Jun 14, 2019

Hi atyachin,
I'm trying to run Emulator using Android-SDK Manager on my ubuntu18.04 EC2 instance by command
"./emulator -avd MyEmulator27" gives Error like:
"ERROR: x86 emulation currently requires hardware acceleration!"
i Checked with few things below:

  • The server instance doesnot support hardware virtualization (checked by command returns '0': egrep -c '(vmx|svm)' /proc/cpuinfo)
  • also checked CPU support for KVM by: kvm-ok gives "KVM acceleration can NOT be used"
    so is that means i can't run Emulator on this instance?
    or any way run on EC2, simlarly also tried with windows EC2 instance.doesnot Worked out!
    please suggest you opinion!
@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Jun 16, 2019

Hi,

Are you using ARM or X86 emulation? You have to use ARM ABI (armeabi-v7a).
Please see my instructions on how to create an ARM image.
Second, when you run the emulator, please make sure to pass the following arguments: -no-window -no-audio -gpu swiftshader_indirect

@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented Jun 17, 2019

previously i was using x86 CPU,but now i changed the instance type to ARM A1.xlarge, facing some dependency issue with brew packages to install appium server for ARM Architecture,once figure out will revert you back,thanks.

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Jun 17, 2019

I was referring to the Android Emulator image (the AVD), not the EC2 instance. I'm using a standard m5.xlarge instance with Ubuntu 16.04 (I guess you can use the newer Ubuntu 18.04 AMI).
The configuration here is running ARM emulation on x86 machine. Indeed it's much slower than running x86 emulation on x86 machine, or ARM emulation on ARM machine, but at the time EC2 didn't have ARM instances.

If you follow the instructions in steps 3-19 above - you should get an AVD image that can be run on such EC2 instance.

You can read more about x86 vs ARM emulation here:
https://stackoverflow.com/questions/30632506/what-is-the-difference-between-the-intel-x86-atom-and-atom-64-system-images/30651276#30651276

If I get a similar configuration to run on an ARM instance, I'll post it separately.

@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented Jun 17, 2019

while creating AVD with command:
./avdmanager create avd -n MyArmEmulator25 -k "system-images;android-25;google_apis;armeabi-v7a" -c 1024M
got Error like: Error: AVD not created
then i dig some solution saying install 32bit dependency for your 64bit-ARM CPU.
doesn't workout even after changing dpkg Arch.
apt install -y libc6:armeabi libncurses5:armeabi libstdc++6:armeabi lib32z1:armeabi libbz2-1.0:armeabi

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Jun 17, 2019

Can you add -v to the create command and send the full error message?

@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented Jun 17, 2019

I created Android system image as per step-14 but don't understood step-15 and 16.

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Jun 17, 2019

You need to run the commands as written. This installs the required packages for the Android Tools.
See additional info here:
https://developer.android.com/studio/command-line/sdkmanager

@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented Jun 17, 2019

these is my step-by-step execution:

  1. Add platform:
    ./sdkmanager "platform-tools" "platforms;android-25"
  2. Add System image:
    ./sdkmanager "system-images;android-25;google_apis;armeabi-v7a"
  3. Accept the Licenses- press "y":
    ./sdkmanager --licenses
  4. Create AVD:
    ./avdmanager create avd -n MyArmEmulator25 -k "system-images;android-25;google_apis;armeabi-v7a" -c 1024M

Auto-selecting single ABI armeabi-v7a===] 100% Fetch remote repository...
Do you wish to create a custom hardware profile? [no] ...( pressed Enter default)
Error: AVD not created.
null

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Jun 17, 2019

It is not clear to me if you are following my steps exactly as written, so it's hard to help here... Please restart from step 1, using the proper instance type (x86 / Ubuntu), follow the steps one by one and let me know at what step does it fail.

@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented Jun 17, 2019

ok,wll follow you step by step,launching 64 bit (x86) Ubuntu 18.04 LTS.

@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented Jun 17, 2019

Hi,
i got something below after step wise:

cd /opt/android-sdk/emulator
./emulator -ports 5554,5555 -avd MyAVD -no-window -no-audio -gpu swiftshader_indirect -show-kernel

binder: 974:987 transaction failed 29189, size 0-0
healthd: battery none chg=a
type=1400 audit(1560782283.899:11): avc: denied { search } for pid=2462 comm="Binder:2462_3" name="run" dev="vdc" ino=29322 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:varrun_file:s0 tclass=dir permissive=0
type=1400 audit(1560782285.759:12): avc: denied { read } for pid=2462 comm="Binder:2462_3" name="/" dev="tmpfs" ino=66 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=dir permissive=0
healthd: battery none chg=a
type=1400 audit(1560782350.039:13): avc: denied { search } for pid=2462 comm="Binder:2462_2" name="run" dev="vdc" ino=29322 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:varrun_file:s0 tclass=dir permissive=0
type=1400 audit(1560782355.639:14): avc: denied { read } for pid=2462 comm="Binder:2462_2" name="/" dev="tmpfs" ino=66 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=dir permissive=0
binder: release 2108:2137 transaction 50880 out, still active
healthd: battery none chg=a
qtaguid: ctrl_untag(u -1): failed to lookup sock_fd=-1 err=-9 pid=2710 tgid=2639 uid=10076
type=1400 audit(1560782407.919:15): avc: denied { search } for pid=2462 comm="Binder:2462_3" name="run" dev="vdc" ino=29322 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:varrun_file:s0 tclass=dir permissive=0

#On Other terminal:

cd /opt/android-sdk/platform-tools
./adb shell "su root pm disable com.google.android.googlequicksearchbox"

Package com.google.android.googlequicksearchbox new state: disabled

means what does it mean.

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Jun 17, 2019

ok, it means that your emulator is running properly and you just connected to it using ADB and disabled the "Ok Google" component (the Android Siri), which causes high CPU consumption and isn't relevant in this use case.

@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented Jun 18, 2019

here,in command
./emulator -ports 5554,5555 -avd MyAVD -no-window -no-audio -gpu swiftshader_indirect -show-kernel
what are these ports 5554 and 5555 mean.
Actually, im trying to Run an .apk or simple testcase on Appium server using Emulator in headless mode, my appium server running on 5423
so in this case how it should this work with cli.

i tried something below but doesnot see app running on emulator:

./adb devices #gives the list of attached devices
emulator-5554 device

./adb -s emulator-5554 install selendroid-test-app-0.17.0.apk #Run .apk on specific device
o/p:
Performing Streamed Install
Success

@yazinsai

This comment has been minimized.

Copy link

@yazinsai yazinsai commented Jul 29, 2019

@atyachin great write up! do you know if it's possible to get the emulator working with GUI if we have a VNC server installed on the EC2 instance?

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Jul 30, 2019

@yazinsai I haven't tried, but you'll need X11 running at minimum and an audio system if you'd like to capture audio.
I managed to run other graphic apps on EC2 instance by using XVFB, ALSA and PulseAudio.
If you already manage to run graphic applications remotely using VNC, then try removing the -no-window and -no-audio options from the startup command.

Also, you'd probably like to keep the -gpu swiftshader_indirect option.
See more details here:
https://developer.android.com/studio/run/emulator-acceleration.html#accel-graphics

@yazinsai

This comment has been minimized.

Copy link

@yazinsai yazinsai commented Jul 31, 2019

@atyachin awesome, worked! Just had to run that command on the VNC client (for anyone trying to do the same).

Also, was able to run this on Ubuntu 18.04 after replacing the first line default-jdk with sudo apt-get install openjdk-8-jre. The default-jdk gets you v11, which appears to be incompatible.

@ramapalani

This comment has been minimized.

Copy link

@ramapalani ramapalani commented Sep 5, 2019

I'm not able to install emulator package, Am I doing something wrong?

[ec2-user@ip-10-81-217-234 android-sdk]$ sdkmanager packages "emulator" --verbose
Info: Parsing /opt/android-sdk/patcher/v4/package.xml                           
Info: Parsing /opt/android-sdk/platform-tools/package.xml
Info: Parsing /opt/android-sdk/system-images/android-25/google_apis/armeabi-v7a/package.xml
Info: Parsing /opt/android-sdk/tools/package.xml
Warning: Failed to find package packages                                        
[ec2-user@ip-10-81-217-234 android-sdk]$ sdkmanager --list | grep emulator
  extras;google;auto                                                                       | 1.1     | Android Auto Desktop Head Unit emulator                             
[ec2-user@ip-10-81-217-234 android-sdk]$ sdkmanager --version
26.1.1
@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Sep 5, 2019

@ramapalani - first ,it looks like you are running on Amazon Linux AMI and not on Ubuntu AMI. I didn't test this on Amazon Linux so can't guarantee it'll work properly...
Next, you seem to have an error in your command (you are trying to install a package named "packages").
Try removing the word "packages" and simply run:
/opt/android-sdk/tools/bin/sdkmanager "emulator"

@ramapalani

This comment has been minimized.

Copy link

@ramapalani ramapalani commented Sep 5, 2019

Thanks @atyachin
I was trying this on A1 EC2 instance, with ARM based Linux.
emulator binary supports only x86. I was able to get past this on an x86 EC2/Linux OS

@leandroBorgesFerreira

This comment has been minimized.

Copy link

@leandroBorgesFerreira leandroBorgesFerreira commented Sep 10, 2019

Thanks @atyachin!! Saved my day!

@rdeshpande06

This comment has been minimized.

Copy link

@rdeshpande06 rdeshpande06 commented Oct 4, 2019

When I tried
ubuntu@ip :/opt/android-sdk/tools/bin$ sdkmanager "emulator" I got below warning
Warning: Failed to find package emulator

I skipped this :) step and try to create avd manager as below I got below error

emulator" package must be installed!

avdmanager -v create avd -f -n MyAVD -k "system-images;android-25;google_apis;armeabi-v7a" -p "/opt/android-sdk/avd"
Auto-selecting single ABI armeabi-v7a===] 100% Fetch remote repository...
Do you wish to create a custom hardware profile? [no] y
Error: "emulator" package must be installed!
null

I am using A1 EC2 instance, with ARM based Ubuntu 18 Sir can you guide ? or is it required to change my instance/AMI ?

@rdeshpande06

This comment has been minimized.

Copy link

@rdeshpande06 rdeshpande06 commented Oct 4, 2019

I created exact Amazon AWS EC2 (Ubuntu 16.04 / m5.xlarge) instance and followed the steps accordingly now I am getting below error.
PANIC: Unknown AVD name [MyAVD], use -list-avds to see valid list.
HOME is defined but there is no file MyAVD.ini in $HOME/.android/avd
(Note: Directories are searched in the order $ANDROID_AVD_HOME, $ANDROID_SDK_HOME/avd, and $HOME/.android/avd)

@rdeshpande06

This comment has been minimized.

Copy link

@rdeshpande06 rdeshpande06 commented Oct 9, 2019

It was PATH related issue Corrected the path and launch emulator however now it is giving below error continue
healthd: battery l=100 v=0 t=0.0 h=2 st=2 chg=a

@dshato42

This comment has been minimized.

Copy link

@dshato42 dshato42 commented Oct 16, 2019

Hi,
I'm getting this error every time I try to start the emulator

/var/lib/jenkins/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-armel: error while loading shared libraries: libpulse.so.0: cannot open shared object file: No such file or directory

@rdeshpande06

This comment has been minimized.

Copy link

@rdeshpande06 rdeshpande06 commented Oct 16, 2019

im trying to Run an .apk or simple testcase on Appium server using Emulator in headless mode, my appium server running on

I have exact same requirement got same output you have any further guidance will help me

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Oct 16, 2019

@DavidAutomation - Can you share your start command?
libpulse is PulseAudio, which probably isn't installed on your system. Are you trying to run the emulator with audio support?
If not, make sure you pass the -no-audio parameter.

@dshato42

This comment has been minimized.

Copy link

@dshato42 dshato42 commented Oct 17, 2019

I'm using the same command as written in the instructions.
emulator -avd AVDNAME -no-window -no-audio -gpu swiftshader_indirect -show-kernel.
I'm Using the AMAZON LINUX if it is important.

@dshato42

This comment has been minimized.

Copy link

@dshato42 dshato42 commented Oct 17, 2019

[ec2-user@ip-172-31-39-88 tools]$ emulator -avd Twiko -no-window -no-audio -verbose
emulator:Android emulator version 26.0.3.0 (build_id 3965150)
emulator:Found AVD name 'Twiko'
emulator:Found AVD target architecture: arm
emulator:argv[0]: 'emulator'; program directory: '/var/lib/jenkins/android-sdk/tools'
emulator: Found directory: /var/lib/jenkins/android-sdk/system-images/android-23/google_apis/armeabi-v7a/

emulator:Probing for /var/lib/jenkins/android-sdk/system-images/android-23/google_apis/armeabi-v7a//kernel-ranchu: file exists
emulator:Auto-config: -engine qemu2 (based on configuration)
emulator: Found directory: /var/lib/jenkins/android-sdk/system-images/android-23/google_apis/armeabi-v7a/

emulator:try dir /var/lib/jenkins/android-sdk/tools
emulator:try dir .
emulator:try dir ../emulator
emulator:Found target-specific 64-bit emulator binary: /var/lib/jenkins/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-armel
emulator:Adding library search path: '../emulator/lib64'
emulator:Adding library search path: '../emulator/lib64/gles_swiftshader'
emulator:Adding library search path: '../emulator/lib64/gles_angle'
emulator:Adding library search path: '../emulator/lib64/gles_angle9'
emulator:Adding library search path: '../emulator/lib64/gles_angle11'
emulator:Adding library search path: '../emulator/lib64/libstdc++'
emulator: Adding library search path for Qt: '../emulator/lib64/qt/lib'
emulator: Setting Qt plugin search path: QT_QPA_PLATFORM_PLUGIN_PATH=../emulator/lib64/qt/plugins
emulator: Running :/var/lib/jenkins/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-armel
emulator: qemu backend: argv[00] = "/var/lib/jenkins/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-armel"
emulator: qemu backend: argv[01] = "-avd"
emulator: qemu backend: argv[02] = "Twiko"
emulator: qemu backend: argv[03] = "-no-window"
emulator: qemu backend: argv[04] = "-no-audio"
emulator: qemu backend: argv[05] = "-verbose"
emulator: Concatenated backend parameters:
/var/lib/jenkins/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-armel -avd Twiko -no-window -no-audio -verbose
/var/lib/jenkins/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-armel: error while loading shared libraries: libpulse.so.0: cannot open shared object file: No such file or directory

the logs of the emulator init

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Oct 17, 2019

@DavidAutomation I'm not entirely sure why it requires PulseAudio but you can try running the following and see if you get any progress:
sudo apt install libpulse-dev

@dshato42

This comment has been minimized.

Copy link

@dshato42 dshato42 commented Oct 17, 2019

I'm working on Amazon-linux not ubunto.
I have already try to install the package and I'm getting the same answer 1065 packages excluded due to repository priority protections
No package libpulse-dev available.
Error: Nothing to do

@atyachin

This comment has been minimized.

Copy link
Owner Author

@atyachin atyachin commented Oct 17, 2019

Ohh, in this case It'll be hard for me to help. I tried running the Emulator on Amazon Linux before without success so switched to the Ubuntu AMI...

@dshato42

This comment has been minimized.

Copy link

@dshato42 dshato42 commented Oct 24, 2019

Hi,
I getting this issue after switching to ubuntu as you suggested.
those are the prints that I'm getting after running the emulator command.

statvfs('/opt/android-sdk/avd/snapshots/default_boot/ram.img') failed: No such file or directory
emulator: WARNING: encryption is off
ERROR: Insufficient RAM free for launching emulator.
Please free up memory (close other programs and files),
or decrease the AVD RAM size and try again.

please advice.

@rdeshpande06

This comment has been minimized.

Copy link

@rdeshpande06 rdeshpande06 commented Oct 24, 2019

@atyachin Thanks I successfully launched emulator on ubuntu machine now I am trying to execute some automation scripts on emulator with appium 1.15 server however I am getting error process system is not responding app is launched successfully but while entering data it is giving error
do you have an any idea ?

@indranil32

This comment has been minimized.

Copy link

@indranil32 indranil32 commented Dec 5, 2019

sudo apt install default-jdk -> do not run this in Ubuntu 18 as that will install JDK 11 which android tools will complain about.
Instead - sudo apt install openjdk-8-jdk openjdk-8-jre

To accept all licenses -> yes | ./sdkmanager --licenses
To wait till emulator comes up - adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'

@indranil32

This comment has been minimized.

@kaiosoft

This comment has been minimized.

Copy link

@kaiosoft kaiosoft commented Dec 7, 2019

@atyachin what you mean "re-login" line 10

@rootmonty

This comment has been minimized.

Copy link

@rootmonty rootmonty commented Dec 12, 2019

@atyachin

I have one doubt,
It is slightly trivial but I want to know when have my emulator finished starting successfully, there is some logs i am getting continuously
after executing line 42 and its not failed, its going continuously

@priyamvadab

This comment has been minimized.

Copy link

@priyamvadab priyamvadab commented Feb 25, 2020

@atyachin on our ec2 instance, we are not able to reach http://dl.google.com/ to get image from repository. what is the link to download system image
"system-images;android-25;google_apis;armeabi-v7a" manually. My plan is to deploy image on artifactory and wget on ec2 instance

@GauravP123

This comment has been minimized.

Copy link

@GauravP123 GauravP123 commented Apr 7, 2020

/sdkmanager --list is not showing emulator in the available package

/opt/android-sdk/tools/bin/sdkmanager "emulator" gives
Warning: Failed to find package emulator

I am trying it on EC2 A1.metal instance

@dimple-doshi

This comment has been minimized.

Copy link

@dimple-doshi dimple-doshi commented May 8, 2020

I am trying the same steps on EC2 instance(Platform details:Linux/UNIX, Instance type:m4.large) from jenkins - execute shell:
Able to run create avd, java_home, android_sdk_root, android_home is all set.

On running /opt/android-sdk/emulator/emulator -ports 5554,5555 -avd MyAVD -no-window -no-audio -gpu auto -show-kernel
I get the following:
emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
emulator: WARNING: encryption is off
Failed to open libEGL_translator: [libGL.so.1: cannot open shared object file: No such file or directory]
Failed to init_egl_dispatch
emulator: ERROR: OpenGLES initialization failed!
emulator: ERROR: OpenGLES emulation library could not be initialized!
emulator: ERROR: OpenGLES emulation failed to initialize. Please consider the following troubleshooting steps:

  1. Make sure your GPU drivers are up to date.

  2. Erase and re-download the emulator ($ANDROID_SDK_ROOT/emulator).

  3. Try software rendering: Go to Extended Controls > Settings > Advanced tab and change "OpenGL ES renderer (requires restart)" to "Swiftshader".

Or, run emulator from command line with "-gpu swiftshader_indirect". 4. Please file an issue to https://issuetracker.google.com/issues?q=componentid:192727 and provide your complete CPU/GPU info plus OS and display setup.

crashhandler_die: fatal: OpenGLES emulation failed to initialize. Please consider the following troubleshooting steps:

  1. Make sure your GPU drivers are up to date.

  2. Erase and re-download the emulator ($ANDROID_SDK_ROOT/emulator).

  3. Try software rendering: Go to Extended Controls > Settings > Advanced tab and change "OpenGL ES renderer (requires restart)" to "Swiftshader".

Or, run emulator from command line with "-gpu swiftshader_indirect". 4. Please file an issue to https://issuetracker.google.com/issues?q=componentid:192727 and provide your complete CPU/GPU info plus OS and display setup.

Segmentation fault (core dumped)
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Some help around this?

@felipeloha

This comment has been minimized.

Copy link

@felipeloha felipeloha commented May 28, 2020

hello!

did you use this with android 28?
is it possible to do it at all?
the new sdk downloads are the command line tools and the corresponding system-image would be system-images;android-28;google_apis;x86_64 which does not have the ARM ABI option

thanks in advance

@wajahatlateef

This comment has been minimized.

Copy link

@wajahatlateef wajahatlateef commented Jun 15, 2020

hello
while running emulator by this command
/opt/android-sdk/emulator/emulator -ports 5554,5555 -avd MyAVD -no-window -no-audio -gpu swiftshader_indirect -show-kernel
getting following error
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/opt/android-sdk/]!

@mddrill

This comment has been minimized.

Copy link

@mddrill mddrill commented Jun 23, 2020

I am getting the same error as @dimple-doshi

Using

echo no | android-sdk-linux/tools/bin/avdmanager create avd --force --name testAVD --package "system-images;android-25;google_apis;armeabi-v7a"
...
android-sdk-linux/emulator/emulator  -ports 5554,5555 -avd testAVD -no-audio -no-window -gpu swiftshader_indirect -show-kernel &

Getting

adb: no emulators found
 Waiting for emulator to start
 emulator: WARNING: encryption is off
 emulator: ERROR: Could not load OpenGLES emulation library [libOpenglRender]: libGL.so.1: cannot open shared object file: No such file or directory
 emulator: ERROR: Retrying in program directory/lib64...
 emulator: ERROR: Could not load OpenGLES emulation library [<path to>/android-sdk-linux/emulator/qemu/linux-x86_64/lib64/libOpenglRender]: <path to>/android-sdk-linux/emulator/qemu/linux-x86_64/lib64/libOpenglRender.so: cannot open shared object file: No such file or directory (2nd try)
 emulator: ERROR: OpenGLES emulation failed to initialize. Please consider the following troubleshooting steps:
 1. Make sure your GPU drivers are up to date.
 2. Erase and re-download the emulator ($ANDROID_SDK_ROOT/emulator).
 3. Try software rendering: Go to Extended Controls > Settings > Advanced tab and change "OpenGL ES renderer (requires restart)" to "Swiftshader".
 Or, run emulator from command line with "-gpu swiftshader_indirect". 4. Please file an issue to https://issuetracker.google.com/issues?q=componentid:192727 and provide your complete CPU/GPU info plus OS and display setup.
 crashhandler_die: fatal: OpenGLES emulation failed to initialize. Please consider the following troubleshooting steps:
 1. Make sure your GPU drivers are up to date.
 2. Erase and re-download the emulator ($ANDROID_SDK_ROOT/emulator).
 3. Try software rendering: Go to Extended Controls > Settings > Advanced tab and change "OpenGL ES renderer (requires restart)" to "Swiftshader".
 Or, run emulator from command line with "-gpu swiftshader_indirect". 4. Please file an issue to https://issuetracker.google.com/issues?q=componentid:192727 and provide your complete CPU/GPU info plus OS and display setup.

What am I doing wrong here?

@marz-hunter

This comment has been minimized.

Copy link

@marz-hunter marz-hunter commented Jun 28, 2020

emulator: ERROR: Not enough disk space to run AVD 'MyAVD'. Exiting...

@kukabi

This comment has been minimized.

Copy link

@kukabi kukabi commented Jun 29, 2020

@atyachin Thanks very much for this document, it helped me get an emulator running, and I get 1 from adb wait-for-device shell getprop sys.boot_completed, which I think means that the emulator has completed booting and is ready.

But when I try to install an APK using adb install file_name.apk the command line gets stuck at Performing Streamed Install. I'm also not able to install the app using Gradle (I have built the app on the EC2 instance using Gradle).

Does anyone have an idea why this could be happening?

@nhphong

This comment has been minimized.

Copy link

@nhphong nhphong commented Jun 30, 2020

@kukabi
adb shell getprop sys.boot_completed returns 1 only indicates that the system has been booted but the services are just starting to load...
If you adb install right at that moment, there's a chance that necessary components for Package Manager are NOT ready yet. The result could be a dead-lock that causes your command adb install to get stuck. Eventually the Android WatchDog may restart your emulator.

Watchdog: *** WATCHDOG KILLING SYSTEM PROCESS: Blocked in handler on PackageManager (PackageManager)

I suggest that you open another console and run adb logcat to see what's going on with the system.

@kukabi

This comment has been minimized.

Copy link

@kukabi kukabi commented Jun 30, 2020

@nhphong thanks a lot, I will test in a bit and update here.

@kukabi

This comment has been minimized.

Copy link

@kukabi kukabi commented Jun 30, 2020

@nhphong Actually it worked this time, but it took 10 minutes to install the APK. I'm running adb install from another window, and the last time I didn't wait thinking the process was frozen. You may find the logcat output here. Do you know if there's a way to shorten this time?

@kukabi

This comment has been minimized.

Copy link

@kukabi kukabi commented Jun 30, 2020

Though I'm guessing it's because it's an armeabi-v7a. I remember it was extremely slow to run one locally too.

@kukabi

This comment has been minimized.

Copy link

@kukabi kukabi commented Jun 30, 2020

@nhphong So I got it all working on an EC2 instance (Ubuntu 18.04) including some passing instrumented tests but managed to get the WATCHDOG KILLING SYSTEM PROCESS error on a Docker instance (again, Ubuntu 18.04) on my laptop. Emulator restarted and I got adb: failed to install. What is a good way to be certain that the emulator is ready for adb install?

@nhphong

This comment has been minimized.

Copy link

@nhphong nhphong commented Jul 1, 2020

@kukabi
Use this to check when the boot animation finished

adb shell getprop init.svc.bootanim

For example:

adb wait-for-device shell 'while [[ $(getprop init.svc.bootanim) != stopped ]]; do sleep 1; done;'
@nhphong

This comment has been minimized.

Copy link

@nhphong nhphong commented Jul 1, 2020

Note that the above approach does not work if you start the emulator with -no-boot-anim option (for example, when you run a headless emulator on the memory)

@lasley

This comment has been minimized.

Copy link

@lasley lasley commented Jul 9, 2020

Thanks for this gist.

  1. We must use ARM ABI, since x86 requires KVM and EC2 instance doesn't support HW virtualization.

This is no longer the case- You can use x86 virtualization on any of the .metal EC2 instances, which provide direct HW access.

Here's the release announcement + case study: https://aws.amazon.com/jp/blogs/aws/new-amazon-ec2-bare-metal-instances-with-direct-access-to-hardware/

@jankowskimarcin

This comment has been minimized.

Copy link

@jankowskimarcin jankowskimarcin commented Aug 21, 2020

Emulator on this solution is extremely slow do someone have experience with Amazon EC2 A1 Instances ?

@kukabi

This comment has been minimized.

Copy link

@kukabi kukabi commented Aug 21, 2020

We ended up GitHub actions with a Mac OS X virtual machine and we're very happy. Here's the test workflow.

Emulator on this solution is extremely slow do someone have experience with Amazon EC2 A1 Instances ?

@jankowskimarcin

This comment has been minimized.

Copy link

@jankowskimarcin jankowskimarcin commented Aug 21, 2020

@kukabi the point is to use Amazon infra

@brunoaduarte

This comment has been minimized.

Copy link

@brunoaduarte brunoaduarte commented Sep 18, 2020

Is it possible to run multiple emulators > 20 in this infrastructure @atyachin ?

@xuguozhen

This comment has been minimized.

Copy link

@xuguozhen xuguozhen commented Oct 6, 2020

Hi,All
I want to boot Android with UEFI in an ARM virtual machine,is there any feasible way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment