blob: 9d4ee93fcedefd98842b2e757195da34e3c3b787 [file] [log] [blame] [view]
Andrew Grieveae094e392018-06-15 16:10:221# Using an Android Emulator
2Always use x86 emulators. Although arm emulators exist, they are so slow that
3they are not worth your time.
4
5## Building for Emulation
6You need to target the correct architecture via GN args:
7```
8target_cpu = "x86"
9```
10
11## Creating an Emulator Image
12By far the easiest way to set up emulator images is to use Android Studio.
13If you don't have an [Android Studio project](android_studio.md) already, you
14can create a blank one to be able to reach the Virtual Device Manager screen.
15
16Refer to: https://developer.android.com/studio/run/managing-avds.html
17
18Where files live:
19 * System partition images are stored within the sdk directory.
20 * Emulator configs and data partition images are stored within
21 `~/.android/avd/`.
22
23When creating images:
24 * Choose a skin with a small screen for better performance (unless you care
25 about testing large screens).
26 * Under "Advanced":
27 * Set internal storage to 4000MB (component builds are really big).
28 * Set SD card to 1000MB (our tests push a lot of files to /sdcard).
29
30Known issues:
31 * Our test & installer scripts do not work with pre-MR1 Jelly Bean.
32 * Component builds do not work on pre-KitKat (due to the OS having a max
33 number of shared libraries).
34 * Jelly Bean and KitKat images sometimes forget to mount /sdcard :(.
35 * This causes tests to fail.
36 * To ensure it's there: `adb -s emulator-5554 shell mount` (look for /sdcard)
37 * Can often be fixed by editing `~/.android/avd/YOUR_DEVICE/config.ini`.
38 * Look for `hw.sdCard=no` and set it to `yes`
39
40## Starting an Emulator from the Command Line
41Refer to: https://developer.android.com/studio/run/emulator-commandline.html.
42
43Note: Ctrl-C will gracefully close an emulator.
44
45If running under remote desktop:
46```
47sudo apt-get install virtualgl
48vglrun ~/Android/Sdk/tools/emulator @EMULATOR_ID
49```
50
51## Using an Emulator
52 * Emulators show up just like devices via `adb devices`
53 * Device serials will look like "emulator-5554", "emulator-5556", etc.
54