Always use x86 emulators (or x86_64 for testing 64-bit APKs). Although arm emulators exist, they are so slow that they are not worth your time.
You need to target the correct architecture via GN args:
target_cpu = "x86" # or "x64" if you have an x86_64 emulator
By far the easiest way to set up emulator images is to use Android Studio. If you don't have an Android Studio project already, you can create a blank one to be able to reach the Virtual Device Manager screen.
Where files live:
Choose a skin with a small screen for better performance (unless you care about testing large screens).
Android Studio's image labels roughly translate to the following:
|AVD “Target”||Virtual Device Configuration tab||GMS?||Build Properties|
|Google Play||“Recommended” (the default tab)||This has GMS|
|Google APIs||“x86 Images”||This has GMS|
|No label||“x86 Images”||AOSP image, does not have GMS|
“Show Advanced Settings” > scroll down:
adb -s emulator-5554 shell mount(look for /sdcard)
hw.sdCard=noand set it to
Running tests on two emulators is twice as fast as running on one. Rather than use the UI to create additional avds, you can clone an existing one via:
$ tools/android/emulator/clone_avd.py \ --source-ini ~/.android/avd/EMULATOR_ID.ini \ --dest-ini ~/.android/avd/EMULATOR_ID_CLONED.ini \ --display-name "Cloned Emulator"
$ ~/Android/Sdk/emulator/emulator @EMULATOR_ID
You can run an emulator without creating a window on your desktop (useful for
$ ~/Android/Sdk/emulator/emulator -no-window @EMULATOR_ID
Unlike physical devices, an emulator's
/system partition cannot be modified by default (even on rooted devices). If you need to do so (such as to remove a system app), you can start your emulator like so:
$ ~/Android/Sdk/emulator/emulator -writable-system @EMULATOR_ID
For better graphics performance, use virtualgl (Googlers, see http://go/virtualgl):
$ vglrun ~/Android/Sdk/emulator/emulator @EMULATOR_ID