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 **Preferences** &gt; **Appearance & Behavior** &gt; **System Settings** &gt; **Android SDK**. From **SDK Platforms**, 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`.
58
59Add the following lines to your **/.zprofile** or **~/.zshrc** (if you are using bash, then **~/.bash_profile** or **~/.bashrc**) config file:
60
61<Terminal
62  cmd={[
63    'export ANDROID_HOME=$HOME/Library/Android/sdk',
64    'export PATH=$PATH:$ANDROID_HOME/emulator',
65    'export PATH=$PATH:$ANDROID_HOME/platform-tools',
66  ]}
67  cmdCopy="export ANDROID_HOME=$HOME/Library/Android/sdk && export PATH=$PATH:$ANDROID_HOME/emulator && export PATH=$PATH:$ANDROID_HOME/platform-tools"
68/>
69
70</Step>
71
72<Step label="7">
73
74Reload the path environment variables in your current shell:
75
76<Terminal cmd={['# for bash', 'source $HOME/.bashrc', '', '# for zsh', 'source $HOME/.zshrc']} />
77
78</Step>
79
80<Step label="8">
81
82Finally, make sure that you can run `adb` from your terminal.
83
84</Step>
85
86## Set up a virtual device
87
88<Step label="1">
89On the Android Studio main screen, click **More Actions**, then **Virtual Device Manager** in the dropdown.
90
91<ImageSpotlight
92  alt="Android Studio configure."
93  src="/static/images/android-studio/virtual-device.png"
94  containerStyle={{ paddingBottom: 0 }}
95/>
96
97</Step>
98
99<Step label="2">
100
101Click the **Create device** button.
102
103<ImageSpotlight
104  alt="Android Studio create virtual device."
105  src="/static/images/android-studio/create-device.png"
106  containerStyle={{ paddingBottom: 0 }}
107/>
108
109</Step>
110
111<Step label="3">
112
113Under **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.
114
115<ImageSpotlight
116  alt="Android Studio create virtual device hardware selection."
117  src="/static/images/android-studio/select-hardware.png"
118  containerStyle={{ paddingBottom: 0 }}
119/>
120
121</Step>
122
123<Step label="4">
124
125Select an OS version to load on the emulator (probably one of the system images in the **Recommended** tab), and download the image.
126
127<ImageSpotlight
128  alt="Android Studio create virtual device os selection."
129  src="/static/images/android-studio/select-os.png"
130  containerStyle={{ paddingBottom: 0 }}
131/>
132
133</Step>
134
135<Step label="5">
136
137Change 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.
138
139</Step>
140
141### Multiple `adb` versions
142
143Having multiple `adb` versions on your system can result in the following error:
144
145<Terminal cmd={["$ adb server version (xx) doesn't match this client (xx); killing..."]} />
146
147This is because the `adb` version on your system is different from the `adb` version on the Android SDK platform-tools.
148
149<Step label="1">
150Open the terminal and check the `adb` version on the system:
151
152<Terminal cmd={['$ adb version']} />
153</Step>
154
155<Step label="2">
156And from the Android SDK platform-tool directory:
157
158<Terminal cmd={[
159  '$ cd ~/Library/Android/sdk/platform-tools',
160  '$ ./adb version'
161]} cmdCopy="cd ~/Library/Android/sdk/platform-tools && ./adb version" />
162</Step>
163
164<Step label="3">
165Copy `adb` from Android SDK directory to `usr/bin` directory:
166
167<Terminal cmd={['$ sudo cp ~/Library/Android/sdk/platform-tools/adb /usr/bin']} />
168</Step>
169