1---
2title: Android Studio Emulator
3---
4
5import ImageSpotlight from '~/components/plugins/ImageSpotlight';
6import { Step } from '~/ui/components/Step';
7import { Terminal } from '~/ui/components/Snippet';
8
9If you don't have an Android device available to test with, we recommend using the default emulator that comes with Android Studio.
10If you run into any problems setting it up, follow the steps in this guide.
11
12## Set up Android Studio's tools
13
14<Step label="1">
15
16[Download](https://developer.android.com/studio) and install Android Studio 3.0+.
17
18</Step>
19
20<Step label="2">
21
22Select **"Standard"** for the **"Install Type"** inside the wizard.
23
24</Step>
25
26<Step label="3">
27Inside Android Studio, go to **Preferences > Appearance & Behavior > System Settings > Android SDK**.
28Click on the **"SDK Tools"** tab and make sure you have at least one version of the **"Android SDK Build-Tools"** installed.
29
30<ImageSpotlight
31  alt="Android SDK build tools"
32  src="/static/images/android-studio-build-tools.png"
33/>
34</Step>
35
36<Step label="4">
37Copy or remember the path listed in the box that says **"Android SDK Location"**.
38
39<ImageSpotlight
40  alt="Android SDK location"
41  src="/static/images/android-studio-sdk-location.png"
42/>
43</Step>
44
45<Step label="5">
46If you are on macOS or Linux, add an [environment variable](https://developer.android.com/studio/command-line/variables#envar) pointing to the Android SDK location
47in `~/.bash_profile` (or `~/.zshenv` if you use Zsh) - for example:`export ANDROID_HOME=/your/path/here`. Copy and paste these two lines to do this automatically for Bash and Zsh:
48
49```bash
50[ -d "$HOME/Library/Android/sdk" ] && ANDROID_HOME=$HOME/Library/Android/sdk || ANDROID_HOME=$HOME/Android/Sdk
51echo "export ANDROID_HOME=$ANDROID_HOME" >> ~/`[[ $SHELL == *"zsh" ]] && echo '.zshenv' || echo '.bash_profile'`
52```
53</Step>
54
55<Step label="6">
56On macOS, you will also need to add `platform-tools` to your `~/.bash_profile` (or `~/.zshenv` if you use Zsh) - for example: `export PATH=/your/path/here:$PATH`.
57Copy and paste this line to do this automatically for Bash and Zsh:
58
59```bash
60echo "export PATH=$ANDROID_HOME/platform-tools:\$PATH" >> ~/`[[ $SHELL == *"zsh" ]] && echo '.zshenv' || echo '.bash_profile'`
61```
62</Step>
63
64<Step label="7">
65Reload the path environment variables by running:
66
67```bash
68source ~/`[[ $SHELL == *"zsh" ]] && echo '.zshenv' || echo '.bash_profile'`
69```
70</Step>
71
72<Step label="8">
73
74Finally, make sure that you can run `adb` from your terminal.
75
76</Step>
77
78## Set up a virtual device
79
80<Step label="1">
81On the Android Studio main screen, click **"More Actions"**, then **"Virtual Device Manager"** in the dropdown.
82
83<ImageSpotlight
84  alt="Android Studio configure"
85  src="/static/images/android-studio-configure.png"
86  containerStyle={{ paddingBottom: 0 }}
87/>
88
89If you already have a project, then the menu will show up under the three dots menu in the top right corner of the window.
90
91<ImageSpotlight
92  alt="Android Studio configure alternate"
93  src="/static/images/android-studio-configure-2.png"
94  containerStyle={{ paddingBottom: 0 }}
95/>
96</Step>
97
98<Step label="2">
99Press the **"Create device"** button.
100
101<ImageSpotlight
102  alt="Android Studio create virtual device"
103  src="/static/images/android-studio-avd-manager.png"
104  containerStyle={{ paddingBottom: 0 }}
105/>
106</Step>
107
108<Step label="3">
109  Choose the type of hardware you'd like to emulate. We recommend testing against a variety of
110  devices, but if you're unsure where to start, the newest device in the Pixel line could be a good
111  choice.
112</Step>
113
114<Step label="4">
115  Select an OS version to load on the emulator (probably one of the system images in the
116  **"Recommended"** tab), and download the image.
117</Step>
118
119<Step label="5">
120  Change any other settings you'd like, and press **"Finish"** to create the virtual device. You can
121  now run this device anytime by pressing the Play button in the AVD Manager window.
122</Step>
123
124### Multiple `adb` versions
125
126Having multiple `adb` versions on your system can result in the error `adb server version (xx) doesn't match this client (xx); killing...`
127
128This is because the adb version on your system is different from the adb version on the android sdk platform-tools.
129
130<Step label="1">
131Open the terminal and check the `adb` version on the system:
132
133<Terminal cmd={['$ adb version']} />
134</Step>
135
136<Step label="2">
137And from the Android SDK platform-tool directory:
138
139<Terminal cmd={[
140  '$ cd ~/Library/Android/sdk/platform-tools',
141  '$ ./adb version'
142]} cmdCopy="cd ~/Library/Android/sdk/platform-tools && ./adb version" />
143</Step>
144
145<Step label="3">
146Copy `adb` from Android SDK directory to `usr/bin` directory:
147
148<Terminal cmd={['$ sudo cp ~/Library/Android/sdk/platform-tools/adb /usr/bin']} />
149</Step>
150