Skip to content

Instantly share code, notes, and snippets.

@atyachin
Last active August 22, 2024 09:26
Show Gist options
  • Save atyachin/cf1690085173e1fabc07b9acc7af3de6 to your computer and use it in GitHub Desktop.
Save atyachin/cf1690085173e1fabc07b9acc7af3de6 to your computer and use it in GitHub Desktop.
Installing and running Android Emulator on Amazon AWS EC2 (Ubuntu 16.04 / m5.xlarge)
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.
@jankowskimarcin
Copy link

@kukabi the point is to use Amazon infra

@brunoaduarte
Copy link

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

@xuguozhen
Copy link

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

@jaejinkorean
Copy link

I keep getting "Process system isn't responding". I was using t2.xlarge Ubuntu x86 instance

@atyachin
Copy link
Author

atyachin commented Jun 6, 2022

@Sarimsaljook
Copy link

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.

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