-
-
Save atyachin/cf1690085173e1fabc07b9acc7af3de6 to your computer and use it in GitHub Desktop.
Update (2022): https://gist.github.com/atyachin/2f7c6054c4cd6945397165a23623987d | |
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. |
@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
?
@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;'
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)
Thanks for this gist.
- 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/
Emulator on this solution is extremely slow do someone have experience with Amazon EC2 A1 Instances ?
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 ?
@kukabi the point is to use Amazon infra
Is it possible to run multiple emulators > 20 in this infrastructure @atyachin ?
Hi,All
I want to boot Android with UEFI in an ARM virtual machine,is there any feasible way?
I keep getting "Process system isn't responding". I was using t2.xlarge Ubuntu x86 instance
Having an issue while running the emulator:
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.
I have already tried everything regarding the ram size modifications in the config files to changing the storage setting on the Ec2 but it won’t work.
Though I'm guessing it's because it's an
armeabi-v7a
. I remember it was extremely slow to run one locally too.