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. |
This comment has been minimized.
This comment has been minimized.
Hi, Are you using ARM or X86 emulation? You have to use ARM ABI (armeabi-v7a). |
This comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
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). 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: If I get a similar configuration to run on an ARM instance, I'll post it separately. |
This comment has been minimized.
This comment has been minimized.
while creating AVD with command: |
This comment has been minimized.
This comment has been minimized.
Can you add -v to the create command and send the full error message? |
This comment has been minimized.
This comment has been minimized.
I created Android system image as per step-14 but don't understood step-15 and 16. |
This comment has been minimized.
This comment has been minimized.
You need to run the commands as written. This installs the required packages for the Android Tools. |
This comment has been minimized.
This comment has been minimized.
these is my step-by-step execution:
Auto-selecting single ABI armeabi-v7a===] 100% Fetch remote repository... |
This comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
ok,wll follow you step by step,launching 64 bit (x86) Ubuntu 18.04 LTS. |
This comment has been minimized.
This comment has been minimized.
Hi, cd /opt/android-sdk/emulator binder: 974:987 transaction failed 29189, size 0-0 #On Other terminal: cd /opt/android-sdk/platform-tools Package com.google.android.googlequicksearchbox new state: disabled means what does it mean. |
This comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
here,in command i tried something below but doesnot see app running on emulator: ./adb devices #gives the list of attached devices ./adb -s emulator-5554 install selendroid-test-app-0.17.0.apk #Run .apk on specific device |
This comment has been minimized.
This comment has been minimized.
@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? |
This comment has been minimized.
This comment has been minimized.
@yazinsai I haven't tried, but you'll need X11 running at minimum and an audio system if you'd like to capture audio. Also, you'd probably like to keep the |
This comment has been minimized.
This comment has been minimized.
@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 |
This comment has been minimized.
This comment has been minimized.
I'm not able to install emulator package, Am I doing something wrong?
|
This comment has been minimized.
This comment has been minimized.
@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... |
This comment has been minimized.
This comment has been minimized.
Thanks @atyachin |
This comment has been minimized.
This comment has been minimized.
Thanks @atyachin!! Saved my day! |
This comment has been minimized.
This comment has been minimized.
When I tried 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" I am using A1 EC2 instance, with ARM based Ubuntu 18 Sir can you guide ? or is it required to change my instance/AMI ? |
This comment has been minimized.
This comment has been minimized.
I created exact Amazon AWS EC2 (Ubuntu 16.04 / m5.xlarge) instance and followed the steps accordingly now I am getting below error. |
This comment has been minimized.
This comment has been minimized.
It was PATH related issue Corrected the path and launch emulator however now it is giving below error continue |
This comment has been minimized.
This comment has been minimized.
Hi, /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 |
This comment has been minimized.
This comment has been minimized.
I have exact same requirement got same output you have any further guidance will help me |
This comment has been minimized.
This comment has been minimized.
@DavidAutomation - Can you share your start command? |
This comment has been minimized.
This comment has been minimized.
I'm using the same command as written in the instructions. |
This comment has been minimized.
This comment has been minimized.
[ec2-user@ip-172-31-39-88 tools]$ emulator -avd Twiko -no-window -no-audio -verbose emulator:Probing for /var/lib/jenkins/android-sdk/system-images/android-23/google_apis/armeabi-v7a//kernel-ranchu: file exists emulator:try dir /var/lib/jenkins/android-sdk/tools the logs of the emulator init |
This comment has been minimized.
This comment has been minimized.
@DavidAutomation I'm not entirely sure why it requires PulseAudio but you can try running the following and see if you get any progress: |
This comment has been minimized.
This comment has been minimized.
I'm working on Amazon-linux not ubunto. |
This comment has been minimized.
This comment has been minimized.
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... |
This comment has been minimized.
This comment has been minimized.
Hi, statvfs('/opt/android-sdk/avd/snapshots/default_boot/ram.img') failed: No such file or directory please advice. |
This comment has been minimized.
This comment has been minimized.
@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 |
This comment has been minimized.
This comment has been minimized.
To accept all licenses -> |
This comment has been minimized.
This comment has been minimized.
@atyachin Have you tried this ARM EC2 type https://aws.amazon.com/about-aws/whats-new/2018/11/introducing-amazon-ec2-a1-instances/ ? |
This comment has been minimized.
This comment has been minimized.
@atyachin what you mean "re-login" line 10 |
This comment has been minimized.
This comment has been minimized.
I have one doubt, |
This comment has been minimized.
This comment has been minimized.
@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 |
This comment has been minimized.
This comment has been minimized.
I am trying it on EC2 A1.metal instance |
This comment has been minimized.
This comment has been minimized.
I am trying the same steps on EC2 instance(Platform details:Linux/UNIX, Instance type:m4.large) from jenkins - execute shell: On running /opt/android-sdk/emulator/emulator -ports 5554,5555 -avd MyAVD -no-window -no-audio -gpu auto -show-kernel
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:
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) Some help around this? |
This comment has been minimized.
This comment has been minimized.
hello! did you use this with android 28? thanks in advance |
This comment has been minimized.
This comment has been minimized.
hello |
This comment has been minimized.
This comment has been minimized.
I am getting the same error as @dimple-doshi Using
Getting
What am I doing wrong here? |
This comment has been minimized.
This comment has been minimized.
emulator: ERROR: Not enough disk space to run AVD 'MyAVD'. Exiting... |
This comment has been minimized.
This comment has been minimized.
@atyachin Thanks very much for this document, it helped me get an emulator running, and I get But when I try to install an APK using Does anyone have an idea why this could be happening? |
This comment has been minimized.
This comment has been minimized.
@kukabi
I suggest that you open another console and run |
This comment has been minimized.
This comment has been minimized.
@nhphong thanks a lot, I will test in a bit and update here. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Though I'm guessing it's because it's an |
This comment has been minimized.
This comment has been minimized.
@nhphong So I got it all working on an EC2 instance (Ubuntu 18.04) including some passing instrumented tests but managed to get the |
This comment has been minimized.
This comment has been minimized.
@kukabi
For example:
|
This comment has been minimized.
This comment has been minimized.
Note that the above approach does not work if you start the emulator with |
This comment has been minimized.
This comment has been minimized.
Thanks for this gist.
This is no longer the case- You can use x86 virtualization on any of the 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/ |
This comment has been minimized.
This comment has been minimized.
Emulator on this solution is extremely slow do someone have experience with Amazon EC2 A1 Instances ? |
This comment has been minimized.
This comment has been minimized.
We ended up GitHub actions with a Mac OS X virtual machine and we're very happy. Here's the test workflow.
|
This comment has been minimized.
This comment has been minimized.
@kukabi the point is to use Amazon infra |
This comment has been minimized.
This comment has been minimized.
Is it possible to run multiple emulators > 20 in this infrastructure @atyachin ? |
This comment has been minimized.
This comment has been minimized.
Hi,All |
This comment has been minimized.
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:
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!