This guide provides instructions for creating an Android XR application using the Jetpack XR SDK. It covers essential dependencies and project setup in Android Studio for building immersive XR experiences.
Compatibility
The Jetpack XR SDK requires a minSdk
of 24 and must compile to SDK 34 or
higher.
Add dependencies
See the following reference guides to understand necessary dependencies and compatibility issues for each of the libraries in the Jetpack XR SDK:
Then, add the necessary dependencies to your app's build.gradle.kts
file:
Groovy
dependencies { // Required for Java implementation "com.google.guava:listenablefuture:1.0" // Required for Kotlin implementation "org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.9.0" implementation "androidx.xr.runtime:runtime:1.0.0-alpha04" implementation "androidx.xr.scenecore:scenecore:1.0.0-alpha04" implementation "androidx.xr.compose:compose:1.0.0-alpha04" implementation "androidx.xr.compose.material3:material3:1.0.0-alpha08" implementation "androidx.xr.arcore:arcore:1.0.0-alpha04" }
Kotlin
dependencies { // Required for Java implementation("com.google.guava:listenablefuture:1.0") // Required for Kotlin implementation("org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.9.0") implementation("androidx.xr.runtime:runtime:1.0.0-alpha04") implementation("androidx.xr.scenecore:scenecore:1.0.0-alpha04") implementation("androidx.xr.compose:compose:1.0.0-alpha04") implementation("androidx.xr.compose.material3:material3:1.0.0-alpha08") implementation("androidx.xr.arcore:arcore:1.0.0-alpha04") }
See the Hello Android XR sample.
Create a new app in Android Studio using the Basic Headset Activity Template
To create a new project that includes Jetpack Compose for XR, proceed as follows:
- If you're in the Welcome to Android Studio window, click Start a new Android Studio project. If you already have an Android Studio project open, select File > New from the menu bar.
- Select XR from the Template options and then Basic Headset Activity.
- In the Configure your project window, do the following:
- Set the Application name.
- Choose the Project location for your sample.
- Click Finish.
- Verify that the project's build.gradle file is configured correctly, as described in Gradle properties files.