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