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. If 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.
17
18</Step>
19
20<Step label="2">
21
22Open the **Android Studio** app, click **More Actions** and then select **SDK Manager**.
23
24</Step>
25
26<Step label="3">
27
28Open Android Studio, go to **Settings** &gt; **Languages & Frameworks** &gt; **Android SDK**. From the **SDK Platforms** tab, select the latest Android version (API level).
29
30<ImageSpotlight alt="Android SDK Platforms" src="/static/images/android-studio/sdk-platforms.png" />
31
32Then, click on the **SDK Tools** tab and make sure you have at least one version of the **Android SDK Build-Tools** and **Android Emulator** installed.
33
34<ImageSpotlight
35  alt="Android SDK build tools."
36  src="/static/images/android-studio/build-tools.png"
37/>
38</Step>
39
40<Step label="4">
41Copy or remember the path listed in the box that says **Android SDK Location**.
42
43<ImageSpotlight
44  alt="Android SDK location."
45  src="/static/images/android-studio/sdk-location.png"
46/>
47</Step>
48
49<Step label="5">
50
51Click **Apply** and **OK** to install the Android SDK and related build tools.
52
53</Step>
54
55<Step label="6">
56
57If 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 in **~/.bash_profile** (or **~/.zshrc** if you use Zsh). For example: `export ANDROID_HOME=/your/path/here`.
58If you are using Windows, add `%LOCALAPPDATA%\Android\Sdk\emulator` to the Path.
59
60Add the following lines to your **/.zprofile** or **~/.zshrc** (if you are using bash, then **~/.bash_profile** or **~/.bashrc**) config file:
61
62<Terminal
63  cmd={[
64    'export ANDROID_HOME=$HOME/Library/Android/sdk',
65    'export PATH=$PATH:$ANDROID_HOME/emulator',
66    'export PATH=$PATH:$ANDROID_HOME/platform-tools',
67  ]}
68  cmdCopy="export ANDROID_HOME=$HOME/Library/Android/sdk && export PATH=$PATH:$ANDROID_HOME/emulator && export PATH=$PATH:$ANDROID_HOME/platform-tools"
69/>
70
71</Step>
72
73<Step label="7">
74
75Reload the path environment variables in your current shell:
76
77<Terminal cmd={['# for bash', 'source $HOME/.bashrc', '', '# for zsh', 'source $HOME/.zshrc']} />
78
79</Step>
80
81<Step label="8">
82
83Finally, make sure that you can run `adb` from your terminal.
84
85</Step>
86
87## Set up a virtual device
88
89<Step label="1">
90On the Android Studio main screen, click **More Actions**, then **Virtual Device Manager** in the dropdown.
91
92<ImageSpotlight
93  alt="Android Studio configure."
94  src="/static/images/android-studio/virtual-device.png"
95  containerStyle={{ paddingBottom: 0 }}
96/>
97
98</Step>
99
100<Step label="2">
101
102Click the **Create device** button.
103
104<ImageSpotlight
105  alt="Android Studio create virtual device."
106  src="/static/images/android-studio/create-device.png"
107  containerStyle={{ paddingBottom: 0 }}
108/>
109
110</Step>
111
112<Step label="3">
113
114Under **Select Hardware**, choose the type of hardware you'd like to emulate. We recommend testing against a variety of devices, but if you're unsure where to start, the newest device in the Pixel line could be a good choice.
115
116<ImageSpotlight
117  alt="Android Studio create virtual device hardware selection."
118  src="/static/images/android-studio/select-hardware.png"
119  containerStyle={{ paddingBottom: 0 }}
120/>
121
122</Step>
123
124<Step label="4">
125
126Select an OS version to load on the emulator (probably one of the system images in the **Recommended** tab), and download the image.
127
128<ImageSpotlight
129  alt="Android Studio create virtual device os selection."
130  src="/static/images/android-studio/select-os.png"
131  containerStyle={{ paddingBottom: 0 }}
132/>
133
134</Step>
135
136<Step label="5">
137
138Change any other settings you'd like, and press **Finish** to create the virtual device. You can now run this device anytime by pressing the Play button in the AVD Manager window.
139
140</Step>
141
142### Multiple `adb` versions
143
144Having multiple `adb` versions on your system can result in the following error:
145
146<Terminal cmd={["$ adb server version (xx) doesn't match this client (xx); killing..."]} />
147
148This is because the `adb` version on your system is different from the `adb` version on the Android SDK platform-tools.
149
150<Step label="1">
151Open the terminal and check the `adb` version on the system:
152
153<Terminal cmd={['$ adb version']} />
154</Step>
155
156<Step label="2">
157And from the Android SDK platform-tool directory:
158
159<Terminal cmd={[
160  '$ cd ~/Library/Android/sdk/platform-tools',
161  '$ ./adb version'
162]} cmdCopy="cd ~/Library/Android/sdk/platform-tools && ./adb version" />
163</Step>
164
165<Step label="3">
166Copy `adb` from Android SDK directory to `usr/bin` directory:
167
168<Terminal cmd={['$ sudo cp ~/Library/Android/sdk/platform-tools/adb /usr/bin']} />
169</Step>
170