Use the [Android Emulator](https://developer.android.com/studio/run/emulator.html)
to test AR scenarios without a physical device. The Android Emulator lets you
run ARCore apps in a virtual environment with an emulated device that you
control.

## Set up your development environment

Software requirements:

- [Android Studio](https://developer.android.com/studio/) **3.1** or later.

- [Android Emulator](https://developer.android.com/studio/run/emulator.html#Requirements)
  **27.2.9** or later.

## Get Android Studio and SDK tools for ARCore

1. Install [Android Studio](https://developer.android.com/studio/) 3.1 or later.

2. In Android Studio, go to **Preferences \> Appearance and Behavior \> System Settings \> Android SDK**.

3. Select the **SDK Platforms** tab and check **Show Package Details**.

   Under the appropriate Android version select:  

   **Google APIs Intel x86 Atom System Image** API Level 27 or later.
4. Select the **SDK Tools** tab and add **Android Emulator** 27.2.9 or later.

5. Click **OK** to install the selected packages and tools.

6. Click **OK** again to confirm changes.

7. **Accept** the license agreement for the Component Installer.

8. Click **Finish**.

## Create a virtual device with AR support

For more information, see the Android Studio instructions to [Create a
Virtual Device](https://developer.android.com/studio/run/managing-avds.html#createavd).

### Create a new Android Virtual Device (AVD)

1. In Android Studio open the *Device Manager* by clicking **Tools \> Device Manager**.

2. Click **Create Device** , at the top of the *Device Manager* panel.

3. Select or create your desired *Phone* hardware profile and select **Next**.

4. Select an `x86` or `x86_64` system image running **API Level 27 or later**
   and select **Next** .  

   - While physical ARCore devices are supported on API Level 24 or later,
     Android Emulator support requires API Level 27 or later.

   - Only x86-based Android Emulator architectures are supported. Other
     architectures such as `arm64-v8a`, `armeabi-v7`, are not currently
     supported.

5. Verify that your virtual device is configured correctly:

   - Click **Show Advanced Settings**.

   - Make sure that **Camera Back** is set to **VirtualScene**.

6. Click **Finish** to create your AVD.

## Run your app

Test an ARCore app on an AR-supported virtual device in the emulator. To do
this, you can follow the Android Studio instructions to
[Run an app in the Android Emulator](https://developer.android.com/studio/run/emulator.html#runningapp).

> [!NOTE]
> **Note:** To run apps with NDK components in the Android Emulator, your app must be built with [**x86 ABIs**](https://developer.android.com/ndk/guides/abis.html). For an example, see the [**ARCore HelloAR C sample app**](https://github.com/google-ar/arcore-android-sdk/tree/master/samples/hello_ar_c).

### Update Google Play Services for AR

The version of Google Play Services for AR on the emulator is likely out of
date. Follow these instructions to update it:

1. Download the latest **Google_Play_Services_for_AR_1.56.0_x86_for_emulator.apk** from the GitHub
   [releases](https://github.com/google-ar/arcore-android-sdk/releases) page.

2. Install the downloaded APK into each AVD you'd like to use:

   Start the desired AVD, then drag the downloaded APK from your system folder
   (i.e., **Downloads** ) onto the running
   emulator, or install it using `adb` while the virtual device is running:

   ```
   adb install -r Google_Play_Services_for_AR_1.56.0_x86_for_emulator.apk
   ```

   <br />

Repeat these steps process for any additional AVDs you'd like to use.

### Control the virtual scene

When your app connects to ARCore, you'll see an overlay describing how to control
the camera and a status bar below the emulator window.

#### Move the virtual camera

Press and hold **Shift** to access camera movement controls.
Use the following controls to move the camera:

<br />

| Action | What to do |
|---|---|
| Move left or right | Hold **Shift** + press **A** or **D** |
| Move down or up | Hold **Shift** + press **Q** or **E** |
| Move forward or back | Hold **Shift** + press **W** or **S** |
| Change device orientation | Hold **Shift** + move mouse |

<br />

Release **Shift** to return to interactive mode in the emulator.

Use the **Virtual Sensors** tab in [Extended controls](https://developer.android.com/studio/run/emulator.html#extended)
for more precise device positioning.

### Add Augmented Images to the scene

Load images into the emulator's simulated environment to test [Augmented Images](https://developers.google.com/ar/develop/augmented-images).

Use the **Camera** tab in **Extended controls** to add or modify **Scene images**.
There are two image locations, one on the wall and one on the table.

To view these image locations in the scene, launch your emulator, then move the
camera to the dining room area through the door behind the camera's starting
position.

### Troubleshooting tips

- If your ARCore app launches and you see a "This device does not support AR"
  message, check the revision on your system image. Make sure you are using
  **API Level 27 Revision 4 or later**.

- If your ARCore app fails to open the camera when it launches, make sure that
  **Camera Back** is set to **VirtualScene** ,
  as described in the [configuration steps above](https://developers.google.com/ar/develop/java/emulator#configure_the_virtual_device).

- If your ARCore app fails to open with the error message "Failed to create AR
  session" check the app log. If you find a `java.lang.UnsatisfiedLinkError`
  with a message that contains `/lib/arm/libarcore_c.so" is for EM_ARM (40)
  instead of EM_386 (3)`, you may have installed the wrong version of the
  **Google Play Services for AR** apk. Create a new virtual device and install
  the x86 version.