/android-xr-app-migration:android-xr-app-migrationfrom android-xr-app-migration
Adapt an existing Android phone/tablet Jetpack Compose app for Android XR headsets using Compose for XR and SceneCore. Use when adding headset or spatial support, Full Space layouts, spatial panels or Orbiters to an existing app while keeping its phone behaviour, even if the user doesn't say "migrate" (for example "make my app work on Android XR or Galaxy XR", "add Full Space", "show the detail in a second panel", "put the nav rail in an Orbiter", "my XR panels blink or my 3D model renders black"). Also covers optional environments, 3D models, video and Android XR emulator troubleshooting for such an app. Not for display glasses (Jetpack Compose Glimmer) or brand-new XR-only apps.
Ships in android-xr-app-migration. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill comes from porting a real app (Confetti: Kotlin Multiplatform, Compose, Decompose) to Android XR headsets
in October 2026. It used androidx.xr.compose:compose:1.0.0-beta01 and androidx.xr.scenecore/runtime
1.0.0-rc01, on the "Google Play XR Preview API v4" emulator image (rev 3.0.0). There was no headset. Every fact in
references/ says which version it was checked on, when, and how: bytecode, build, emulator, a human looking, or the
docs.
Jetpack XR changes every month. APIs get renamed, deprecated or removed between releases. So treat anything older, including tutorials, blog posts and your own memory, as suspect until you check it. The method in "Verifying a fact" matters more than any single signature here.
adaptive skill for window-size layouts. The main panel's width drives your size classes (step 3).javap -v) before you write
against an API. See "Verifying a fact". Example: Entity.dispose() is public in scenecore rc01, but marked
@Deprecated and @RestrictTo, and its message tells you to use parent = null instead.+, no ranges. Your build should only change when you decide it does.
In any plan or answer you write, name the versions you pinned and tell the reader to confirm them, and their
AGP/compileSdk/minSdk requirements, against the current release notes: whoever reads it later may be on a newer
release than you.LocalSpatialCapabilities.current.isSpatialUiEnabled. A non-null LocalSession only tells you the device is XR:
the session exists in Home Space too. Use it for XR-only controls such as the space toggle, never as a stand-in
for "Full Space". In Home Space the only visible addition is the space toggle.references/api-notes.md) and note each library's
required AGP, compileSdk and minSdk. Ours: AGP 9.2.1 and compileSdk 37 with compose-xr beta01. A separate experiment
(Now in Android) built with compileSdk 36 and needed minSdk 24. Trust the notes, not these numbers../gradlew :app:dependencies.references/api-notes.md links it). A required feature on that list hides the app on Play for XR.
Mark it required="false" if the app works without it. Read the list rather than guessing: plain
android.hardware.camera is not on it, but camera.autofocus and camera.flash are, and the CAMERA
permission implies camera and camera.autofocus. GPS (location.gps), telephony, NFC and the fingerprint and
face biometrics are on it.references/emulator.md.Do these in order. Each step is shippable on its own. Exact signatures and sketches are in references/api-notes.md
and references/navigation-patterns.md.
Add the XR libraries to the Android app module only, and bump AGP or compileSdk if the notes require it. Check that it builds, the tests are back to baseline, and the app is unchanged in Home Space.
Manifest:
<uses-feature android:name="android.software.xr.api.spatial" android:required="false"/>: phones can still
install it. Use required="true" only for an XR-only app.android.window.PROPERTY_XR_ACTIVITY_START_MODE (Home Space or Full Space managed). It
works on <application> or <activity>.configChanges="orientation|screenSize|screenLayout|smallestScreenSize". The
SpatialMainPanel reference says resizing the panel crashes without it.The smallest Full Space: if (isSpatialUiEnabled) Subspace { SpatialMainPanel(SubspaceModifier.movable().resizable()) }
next to your normal content. It reuses the activity window, so no custom panel and no background workaround.
Keep the app's content in the same place in the composition for both spaces: an if (spatial) Host(content) else content() branch recreates the content subtree on every space switch, and with it any state kept inside
(scroll positions, a navigation back stack held in composition). Hoist that state above the branch, or make the
host wrap the same content node in both cases. Confetti's selected day survived the switch because its state lives
in the navigation component, not in the composition.
Toggle: the system window controls do NOT put an app in Full Space; the app must ask. An Orbiter holding a
button that requests the space. Two APIs exist, and both are current:
session.scene.requestFullSpace() / requestHomeSpace() (import androidx.xr.scenecore.scene),
fire-and-forget, returning Unit. This is what the migration used.ComponentActivity.requestFullSpace() / requestHomeSpace(), suspend extensions returning a
SpaceRequestResult (Success, Unsupported, Error, Hidden), so you can react to a refusal.When spatial UI is off, an Orbiter draws its content inline, so the same Orbiter is your Home Space "Enter Full Space" button.
Don't: use Material for XR's SpaceToggleButton (alpha17). It crashes with compose-xr beta01.
SpatialRow { SpatialMainPanel(size); SpatialPanel(size) { Detail() } }. A width on SpatialMainPanel
resizes the activity window, so LocalWindowInfo and your size classes follow. Check what your layout does at that
width: Confetti's list became a grid whose buttons did nothing.SpatialPanels have no window background. Paint colorBackground behind the content, or
translucent UI shows the environment through it.references/navigation-patterns.md.NavigationRail uses fillMaxHeight(), so inside an Orbiter it becomes a
panel-tall slab. Build a pill instead: an Orbiter at CenterStart with a rounded shape, holding a Surface and a
Column of NavigationRailItems. Round the Orbiter's own shape too.EnableXrComponentOverrides was removed upstream (July 2026), and
alpha17 crashes on compose-xr beta01. Material 3 1.4's override hooks are internal.val LocalTopBarContainer = staticCompositionLocalOf<@Composable (@Composable () -> Unit) -> Unit> { { it() } }.
Screens wrap their top bar in LocalTopBarContainer.current { … }. In Full Space the app module provides a
container that registers the bar into one long-lived Orbiter per panel. A new Orbiter per screen blinks on
every navigation.surfaceContainer roles.LocalMinimumInteractiveComponentSize provides 56.dp.SpatialDialog), and no full-screen dialogs. A
Material AlertDialog's window can't be hooked, so draw its content yourself.Orbiter and every composed SpatialElevation creates its
own panel entity, and the docs warn against elevating content that scrolls.rotate) for a wraparound look.SpatialEnvironmentPreference (glb geometry plus an image-based lighting zip),
and preferredPassthroughOpacity. Enable each only when its capability is available. Do this early: it's the most
visible XR moment, and it is your lighting for any 3D content.SpatialGltfModel (needs an opt-in) in the Subspace. Highlight parts with a
KhronosPbrMaterial override, and set metallic to 0. Handing off to Scene Viewer XR is possible but has caveats.
See references/3d-and-video.md.GltfModelEntity placed in metres on the floor. Hide
parts with an invisible MASK material, never with node transforms. Animate at the entity level. See
references/3d-and-video.md.SurfaceEntity is the spatial video API, but it rendered black on the emulator. A PanelEntity
holding a TextureView works there. See references/3d-and-video.md.| Need | Use | Not | Why |
|---|---|---|---|
| Show the app in Full Space | SpatialMainPanel | a custom SpatialPanel with App() | reuses the activity window, background and composition |
| A second screen beside it | SpatialPanel in a SpatialRow | rendering a back-stack child | the child must stay active (lifecycle) |
| Navigation, app bar, actions | Orbiter (one long-lived per panel) | a panel per bar | fewer panels, follows the panel |
| Space toggle | your own button + requestFullSpace() | Material for XR SpaceToggleButton | the alpha17 one crashes on beta01 |
| A model small enough for the content box | SpatialGltfModel | Compose layout, movable | |
| A model bigger than the box, or floor-placed | SceneCore GltfModelEntity in metres | SpatialGltfModel | a Subspace is bound by the recommended box; the floor is only known from the perception/real-world origin |
| Hiding model parts | invisible MASK material override | GltfModelNode.localScale | node transforms don't round-trip in rc01 |
| Video on a headset | SurfaceEntity (unverified on hardware) | stereo, DRM, HDR; the compositor samples it | |
| Video on the emulator | PanelEntity + TextureView | SurfaceEntity | it renders black on XR Preview v4 |
| Component overrides | hand-built Orbiters and hooks | Material for XR alpha17 | removed upstream; crashes on beta01 |
On the pinned versions and the emulator. Check them again when you upgrade. Details are in the references.
Session.scene is an extension: import androidx.xr.scenecore.scene.requestFullSpace() APIs: the SceneCore scene one returns Unit; the Compose for XR
ComponentActivity extension is suspend and returns SpaceRequestResult. Don't await the first or ignore the
second's result.SpaceToggleButton, NavigationSuiteScaffold and
ThreePaneScaffold hit NoSuchMethodError on beta01.Orbiter and every composed SpatialElevation is a panel. Count them; beta01 warns that many panels can
corrupt rendering.Entity.dispose() is deprecated: detach with parent = null. GltfModel and Material are AutoCloseable:
wrap them in use { }.KhronosPbrMaterial defaults to metallic 1.0, so a colour override renders black under dim lighting. Call
setMetallicFactor(0f).GltfModelNode.localScale corrupts nodes, even when you write back the value you just read. Zero gives
NaN, and a tiny scale (1e-4) still corrupts: the problem is the write, not the value. Treat every node transform
setter (localScale, localPose, modelScale, modelPose) as off limits in rc01.setMaterialOverride / clearMaterialOverride throw on mesh-less (group) nodes. Filter to meshes first.Subspace is bound by the recommended content box (about 1.7 × 1.6 × 0.5 m around eye height). Use
requiredSize, or a SceneCore entity, for anything bigger.SurfaceEntity video renders black on the emulator (RenderEyeTarget is not supported).am force-stop on another XR app (e.g. Scene Viewer) leaves a stale input window: every click
dies until you press Home and reopen.content://
with a read grant.Do this whenever a signature, default or behaviour matters and you haven't checked it on your versions.
references/api-notes.md). Look for renames,
removals and known issues. Don't trust a newer release as tested just because it exists.*-testing artifacts.classes.jar from the AAR in the Gradle cache and run javap:
javap -cp classes.jar androidx.xr.scenecore.SurfaceEntity: the real signatures.javap -v … | grep -A3 "Deprecated\|RestrictTo\|ExperimentalSurface": deprecations, restricted APIs and
required opt-ins.getLocalScale / setLocalScale). Kotlin code uses the
property: node.localScale = …. A @JvmField shows up as a public field (e.g. Vector3.Zero).references/api-notes.md: verified signatures and facts by area, each with its version, date and evidence;
release-note links; the renamed-API table; what's unverified.references/emulator.md: setup, sizing, input, adb recipes, and the quirks with their recoveries.references/navigation-patterns.md: list and detail panels, Back order, handing off between spaces, deep links,
and identity-default hooks.references/3d-and-video.md: the tabletop, Scene Viewer, floor placement, hiding parts, life size, animation,
lighting, and the two video routes with code sketches.references/design-numbers.md: Material 3 for XR sizes, distances, elevation and accessibility numbers.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub cmota/android-xr-app-migration-skill --plugin android-xr-app-migration