Android Studio tools for XR

This documentation walks you through using the Android XR Emulator and the Layout Inspector in Android Studio for building an XR app.

Android Studio includes the following new features for XR:

  • Android XR Emulator
  • XR Support in Layout Inspector

Android studio emulator screen

Android XR Emulator

The Android XR Emulator provides a virtualized XR device for testing and debugging your XR apps in Android Studio. It emulates an XR device, allowing you to experience your app in a 3D spatial environment. This lets you build your apps without the need for physical hardware during early development stages, streamlining your workflow and accelerating iteration.

If this is your first time using an emulator with Android Studio, consider reviewing general documentation for the Android emulator.

Launch the Android XR Emulator

After installing the Android XR Emulator, click the Run button in Device Manager on the device.

Android studio device manager screen

Enable the mouse and keyboard

Currently, the emulator supports only mouse and keyboard input. When using the emulator, make sure the keyboard and mouse icon is selected.

Android studio device mouse and keyboard icon

Once you've done this, you can start interacting with various elements within the virtual space by moving the mouse over the emulator window.

Look and move around in the virtual environment

The Android XR emulator renders application elements in a virtual 3D environment. Use the following controls to change the direction of your view, pan, dolly, rotate, and reset:

Android studio pan icon

Pan: Click and drag the mouse to move up, down, and side to side. This will allow viewing the emulator contents from different angles

Android studio dolly icon

Dolly: Click and drag the mouse to move closer or farther from the objects in view

Android studio rotate icon

Rotate: Click and drag the mouse to pivot your view in that direction

Android studio reset icon

Reset: Click this button to return the emulator to the default view

You can also use the following keyboard shortcuts to move around in the virtual environment. To use these while using mouse and keyboard input, hold the Option key (macOS) or Alt key (Windows).

  • W (or up arrow key): Move forward in your current view.
  • A (or left arrow key): Side-step left.
  • S: (or down arrow key): Move backward.
  • D (or right arrow key): Side-step right.
  • Q: Move vertically downward.
  • E: Move vertically upward.

Enable passthrough mode

Use the following menu option to enable or disable a simulated passthrough environment.

Android studio passthrough mode UI

When enabled, passthrough mode will display a simulated indoor environment. Use this mode to test applications in mixed reality.

Android studio emulator screen

Other Emulator Controls

Android studio power icon

Power: Simulates powering the device on or off

Android studio volume up icon Android studio volume down icon

Volume: Simulates volume control

Android studio screenshot icon

Screenshot: Takes a screenshot of the current state of the device

Android studio back icon Android studio home icon Android studio overview icon

Android 3 button control: Simulates the back, Home, and Overview buttons

Troubleshooting

Check the release notes for any known issues and workarounds.

If you encounter a problem that is not a known issue, view the support page for instructions on getting help and reporting issues.

Including a crash report or a bug report will help us better understand the issue. Screenshots and recordings also provide additional details needed. The instructions in this section explain how to upload a crash report and use adb to generate a bug report.

Use the Android Studio Layout Inspector with an XR app

Once you have started building your spatial panels and orbiters, you can inspect your layout with the Android Studio Layout Inspector. If you are unfamiliar with the Layout Inspector, see our guide on layout debugging.

Follow these steps to use the Layout Inspector with your Android XR app:

  1. With your project open in Android Studio, ensure that the embedded Layout Inspector is disabled (uncheck the option and restart Android Studio). Android studio settings page
  2. Run your app.
  3. Once the application deployment has completed, choose Tools > Layout Inspector.

This Layout Inspector will open in an embedded window. After a few seconds, the preview displays on the left and the component tree displays on the right. Orbiters and panels appear as separate objects beneath your main content.

Android studio layout inspector page

Now, you can interact with your app in the emulator. If you want to inspect any component, click it on the preview or in the component tree.

You can see the component attributes by clicking the attributes tab on the right corner.

Android studio layout inspector page

Enable Usage Statistics to help improve Android Studio for XR

Consider enabling usage statistics and sending feedback to help us improve these tools. Because this is a canary version of Android Studio, many of these features are still under development.

Click Settings > Appearance & Behavior > System Settings > Data Sharing, and ensure that Send usage statistics to google is selected.

Android studio settings page