Jetpack Compose for XR
Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |
---|---|---|---|---|
December 12, 2024 | - | - | - | 1.0.0-alpha01 |
Declaring dependencies
To add a dependency on XR compose, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle
file for
your app or module:
Groovy
dependencies { implementation "androidx.xr.compose:compose:1.0.0-alpha01" // Use to write unit tests testImplementation "androidx.xr.compose:compose-testing:1.0.0-alpha01" }
Kotlin
dependencies { implementation("androidx.xr.compose:compose:1.0.0-alpha01") // Use to write unit tests testImplementation("androidx.xr.compose:compose-testing:1.0.0-alpha01") }
For more information about dependencies, see Add build dependencies.
Feedback
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
Version 1.0
Version 1.0.0-alpha01
December 12, 2024
androidx.xr.compose:compose-*1.0.0-alpha01
is released.
Features of Initial Release
Initial developer release of Jetpack Compose for XR. Use familiar Compose concepts such as rows and columns to create spatial UI layouts in XR, whether you're porting an existing 2D app to XR or creating a new XR app from scratch. This library provides subspace and spatial composables: such as spatial panels and orbiters, which let you place your existing 2D Compose or Views-based UI in a spatial layout. It introduces the Volume subspace composable, which allows you to place SceneCore entities, such as 3D models, relative to your UI. Learn more in this developer guide:
Subspace
: This composable can be placed anywhere within your app’s UI hierarchy, allowing you to maintain layouts for 2D and spatial UI without losing context between files. This makes it easier to share things like existing app architecture between XR and other form factors without needing to hoist state through your whole UI tree or re-architect your app.SpatialPanel: A spatial panel is a subspace composable that lets you display app content–for example, you could display video playback, still images, or any other content in a spatial panel.
Orbiter: An orbiter is a spatial UI component. It's designed to be attached to a corresponding spatial panel, and contains navigation and contextual action items related to that spatial panel. For example, if you've created a spatial panel to display video content, you could add video playback controls inside an orbiter.
Volume: Place SceneCore entities, such as 3D models, relative to your UI.
Spatial Layout: You can create multiple spatial panels and place them within a Spatial Layout using
SpatialRow
,SpatialColumn
,SpatialBox
, andSpatialLayoutSpacer
. UseSubspaceModifier
s to customize your layout.Spatial UI components: These elements can be reused in your 2D UI, and their spatial attributes will only be visible when spatial capabilities are enabled.
SpatialDialog
: Panel will push slightly back in z-depth to display an elevated dialog.SpatialPopUp
: Panel will push slightly back in z-depth to display an elevated popupSpatialElevation
:SpatialElevationLevel
can be set to add elevation.
SpatialCapabilities: Spatial capabilities can change as users interact with your app or the system, or can even be changed by your app itself—for example, moving into Home Space or Full Space. To avoid issues, your app needs to check for
LocalSpatialCapabilities.current
to determine which APIs are supported in the current environment.isSpatialUiEnabled
: Spatial UI elements (e.g. SpatialPanel)isContent3dEnabled
: 3D objectsisAppEnvironmentEnabled
: The environmentisPassthroughControlEnabled
: Whether or not the application can control the passthrough stateisSpatialAudioEnabled
: Spatial audio
Known Issues
- Currently a minSDK of 30 is required to use Jetpack Compose for XR. As a workaround you may add the following manifest entry
<uses-sdk tools:overrideLibrary="androidx.xr.scenecore, androidx.xr.compose"/>
to be able to build and run with a minSDK of 23. - Jetpack XR apps currently require requesting
android.permission.SCENE_UNDERSTANDING
permission in the AndroidManifest. - When an app launches directly into Full Space using the
PROPERTY_XR_ACTIVITY_START_MODE
property in their manifest, Activities/Applications are initially opened in Home Space before transitioning into Full Space. - glTFs in Volume Composables may initially flicker at the wrong location.
- Using a SpatialDialog in a panel that has been moved significantly will push the content in the wrong direction.