# Run Sceneform apps in Android Emulator

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.

Hardware requirements:

- You'll also need a development machine that supports **OpenGL ES 3.0** or higher to use Sceneform in your app.

## 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 **Android 8.1 (Oreo)** , select:  

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

5. Click **OK** to install the selected pacakges 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

You can follow the Android Studio instructions to [create a
Virtual Device](https://developer.android.com/studio/run/managing-avds.html#createavd)
with AR support.

### Configure the virtual device

- Select the **Pixel** or **Pixel 2** hardware profile.
- Select the **Oreo: API Level 27: x86: Android 8.1 (Google APIs)** system image.
- Confirm that your virtual device is configured correctly:

  - Go to **Verify Configuration \> Show Advanced Settings**.
  - Make sure that **Camera Back** is set to **VirtualScene**.

## Configure the emulator to support Sceneform

Sceneform requires **OpenGL ES 3.0** or higher.

1. Make sure your emulator is configured to use the latest version of
   OpenGL ES:

   - Click in the running emulator's toolbar.
   - Select **Settings \> Advanced \> OpenGL ES API level \>
     Renderer maximum (up to OpenGL ES 3.1)**.
   - Restart the emulator. When prompted, do not save the current state.
2. After restarting the emulator, briefly interact with the emulated deivce,
   then check whether OpenGL ES 3.0 or higher is being used by grepping the
   device logs:

   <br />

   ```
   adb logcat | grep eglMakeCurrent
   ```

   <br />

   If you see **`ver 3 0`** or higher version, then you can run Sceneform
   apps in the emulator:

   ```
   … …  …  … D EGL_emulation: eglMakeCurrent: 0xebe63540: ver 3 0 (tinfo 0xd104cb40)
   ```

   <br />

   If you see a lower version, then your desktop GPU does not support
   OpenGL ES 3.0 and you must instead use a physical
   [supported device](https://developers.google.com/ar/discover/supported-devices) to run Sceneform apps.

## 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](https://developer.android.com/studio/run/emulator.html#runningapp) to
run an app in the Android Emulator.

> [!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.15.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 onto the running
   emulator, or install it using `adb` while the virtual device is running:

   ```
   adb install -r Google_Play_Services_for_AR_1.15.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 **Option** (macOS) or **Alt** (Linux or Windows) to access camera
movement controls. Use the following controls to move the camera:

<br />

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

<br />

Release **Option** or **Alt** 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.

### Troubleshooting tips

- If your ARCore app launches and you see an "AR Core not supported" message,
  check the revision on your system image. Make sure you are using
  **API Level 27 Revision 4**.

- 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/sceneform/develop/emulator#configure_the_virtual_device).