blob: e4de232bf4748cd3a267e27c7e364fd360c30574 [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
Andrew Grievea0190fd2018-06-15 17:52:4940### Cloning an Image
41Running tests on two emulators is twice as fast as running on one. Rather
42than use the UI to create additional avds, you can clone an existing one via:
43
44```shell
45tools/android/emulator/clone_avd.py \
46 --source-ini ~/.android/avd/EMULATOR_ID.ini \
47 --dest-ini ~/.android/avd/EMULATOR_ID_CLONED.ini \
48 --display-name "Cloned Emulator"
49```
50
Andrew Grieveae094e392018-06-15 16:10:2251## Starting an Emulator from the Command Line
52Refer to: https://developer.android.com/studio/run/emulator-commandline.html.
53
54Note: Ctrl-C will gracefully close an emulator.
55
56If running under remote desktop:
57```
58sudo apt-get install virtualgl
59vglrun ~/Android/Sdk/tools/emulator @EMULATOR_ID
60```
61
62## Using an Emulator
63 * Emulators show up just like devices via `adb devices`
64 * Device serials will look like "emulator-5554", "emulator-5556", etc.
65