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:

- [XR Runtime](https://developer.android.com/jetpack/androidx/releases/xr-runtime)
- [Jetpack SceneCore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore)
- [Jetpack Compose for XR](https://developer.android.com/jetpack/androidx/releases/xr-compose)
- [Material Design for XR](https://developer.android.com/jetpack/androidx/releases/xr-compose-material3)
- [ARCore for Jetpack XR](https://developer.android.com/jetpack/androidx/releases/xr-arcore)

Then, add the necessary dependencies to your app's`build.gradle.kts`file:  

### Groovy

```groovy
dependencies {
    implementation "androidx.xr.runtime:runtime:1.0.0-alpha08"
    implementation "androidx.xr.scenecore:scenecore:1.0.0-alpha09"
    implementation "androidx.xr.compose:compose:1.0.0-alpha08"
    implementation "androidx.xr.compose.material3:material3:1.0.0-alpha12"
    implementation "androidx.xr.arcore:arcore:1.0.0-alpha08"

    // For compatibility with guava, use these dependencies:
    implementation "androidx.xr.arcore:arcore-guava:1.0.0-alpha08"
    implementation "androidx.xr.runtime:runtime-guava:1.0.0-alpha08"
    implementation "androidx.xr.scenecore:scenecore-guava:1.0.0-alpha09"

    // For compatibility with rxjava3, use these dependencies:
    implementation "androidx.xr.arcore:arcore-rxjava3:1.0.0-alpha08"
    implementation "androidx.xr.runtime:runtime-rxjava3:1.0.0-alpha08"
}
```

### Kotlin

```kotlin
dependencies {
    implementation("androidx.xr.runtime:runtime:1.0.0-alpha08")
    implementation("androidx.xr.scenecore:scenecore:1.0.0-alpha09")
    implementation("androidx.xr.compose:compose:1.0.0-alpha08")
    implementation("androidx.xr.compose.material3:material3:1.0.0-alpha12")
    implementation("androidx.xr.arcore:arcore:1.0.0-alpha08")

    // For compatibility with guava, use these dependencies:
    implementation("androidx.xr.arcore:arcore-guava:1.0.0-alpha08")
    implementation("androidx.xr.runtime:runtime-guava:1.0.0-alpha08")
    implementation("androidx.xr.scenecore:scenecore-guava:1.0.0-alpha09")

    // For compatibility with rxjava3, use these dependencies:
    implementation("androidx.xr.arcore:arcore-rxjava3:1.0.0-alpha08")
    implementation("androidx.xr.runtime:runtime-rxjava3:1.0.0-alpha08")
}
```

See the[Hello Android XR sample](https://github.com/android/xr-samples).

### Enable code minification (optional)

If you want to enable code minification and obfuscation using ProGuard for your builds, you must add a dependency on the Android Extensions for XR library. This is required for projects using Jetpack XR`alpha05`or newer.

Add the following`compileOnly`dependency to your module's`build.gradle.kts`file:  

### Groovy

```groovy
dependencies {
    // ... other dependencies
    compileOnly "com.android.extensions.xr:extensions-xr:1.1.0"
}
```

### Kotlin

```kotlin
dependencies {
    // ... other dependencies
    compileOnly("com.android.extensions.xr:extensions-xr:1.1.0")
}
```
| **Caution:** You must use`compileOnly`for this dependency. Using`implementation`or`api`will cause your app to break at runtime.

### 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:

1. 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.
2. Select**XR** from the**Template** options and then**Basic Headset Activity**.
3. In the**Configure your project** window, do the following:
   1. Set the**Application name**.
   2. Choose the**Project location**for your sample.
4. Click**Finish**.
5. Verify that the project's build.gradle file is configured correctly, as described in[Gradle properties files](https://developer.android.com/studio/build#properties-files).