Jetpack Compose
Use this skill when implementing, upgrading, reviewing, or testing AndroidX
Compose UI, Foundation, Runtime, Material 3, compiler-plugin, or BOM code.
Treat those artifacts as separately versioned products: inspect the module's
Gradle declarations, version catalog, and resolved dependency graph before
applying guidance.
Working Method
- Identify the affected surface: build setup, runtime/state, input and focus,
layout/graphics, text, Material 3, Android hosting, or testing.
- Check the resolved version of every relevant artifact. A BOM aligns the
artifacts it manages but does not make every Compose-related product share
one release number.
- Search the topic reference below for renamed, removed, or behavior-changing
APIs before editing call sites.
- Prefer the replacement API over compatibility flags. Several migration
flags existed briefly and were removed in later releases.
- Compile the affected source set, run Compose lint, and exercise UI tests on
the scheduler and host configuration used by the project.
- For Android-only behavior, verify API-level guards, window ownership,
insets, resources, and View/Compose interop rather than assuming common-code
behavior applies unchanged.
Topic Index
| Reference |
Topics |
| Setup, Runtime, and State |
Toolchain floors, BOMs, compiler reports, pausable composition, retained and saveable state, diagnostics |
| Input, Scrolling, and Focus |
Focus, pointer and trackpad input, haptics, overscroll, scrolling, visibility callbacks, indicators |
| Layout, Animation, and Graphics |
Lookahead, shared transitions, FlexBox/Grid, lazy infrastructure, modifier nodes, shadows, shaders, mesh gradients |
| Text, Autofill, and Resources |
Text fields, autosizing, annotations, autofill, selection, fonts, resources, clipboard |
| Material 3 Components |
Component migrations, state APIs, navigation, pickers, tooltips, sheets, sliders, color and inset changes |
| Platform, Window, and Interop |
Insets, window geometry, ComposeView hosting, dialogs/popups, paint and color interop, frame rate |
| Semantics, Accessibility, and Testing |
Semantics tree changes, accessibility, test artifacts, schedulers, hybrid UI scoping |
Breaking Changes First
Toolchain and platform floors
- Compose Animation, Foundation, Runtime, and UI require Android API 23 or
newer from 1.10.0.
- Artifacts built with Kotlin 2.0 require Kotlin Gradle Plugin 2.0.0 or newer.
- Compose 1.12 Android builds require
compileSdk = 37 and Android Gradle
Plugin 9; targetSdk remains an independent choice.
- Compose lint from 1.9.0 requires AGP 8.8.2 or standalone Lint 8.8.2 and an
Android Studio Ladybug-era toolchain or newer.
See Setup, Runtime, and State before an
upgrade changes the build.
Indication migration
After recompiling against 1.9.0, interaction modifiers whose overload omits an
explicit Indication require LocalIndication to provide an
IndicationNodeFactory. A legacy Indication can fail at runtime. Migrate the
implementation or use an explicit-indication overload while bridging. The
temporary isNonComposedClickableEnabled escape hatch is absent from 1.10.0.
State and lifecycle changes
- Remove custom keys from
rememberSaveable; positional scoping is now the
supported behavior.
- A cancelled
PausableComposition must be disposed and cannot be reused.
- Install custom retained-value stores with
LocalRetainedValuesStoreProvider; do not provide the local directly.
retain keeps values across temporary hierarchy removal without
serialization. Do not retain keys or values that can leak resources; mark
unsuitable types with @DoNotRetain.
Semantics and test structure
background, border, and graphicsLayer can add semantics nodes. Tests that
assert exact parent/child/sibling structure are brittle; tag the intended node
or use an ancestor matcher. Replace invisibleToUser() with
hideFromAccessibility(), and retrieve a semantics ID through
fetchSemanticsNode().id.
Text and autofill migrations
- Replace
AutoSize with TextAutoSize.
- Replace deprecated autofill APIs with semantic
fillableData and
onFillData; text autofill needs matching UI and Foundation support.
TextFieldState.edit {} creates an undo entry. Explicitly call
undoState.clearHistory() when programmatic edits should reset history.
- Use
OutputTransformation plus TextFieldBuffer.addStyle; the interim
AnnotatedOutputTransformation API is gone.
Layout and animation removals
- Replace deprecated contextual flow layouts and overflow overloads with
ordinary
FlowRow/FlowColumn or a custom layout.
- Replace
ScaleToBounds with scaleToBounds; removed shared-transition
factories and parameters have no direct compatibility flag.
- Replace
Modifier.meshGradient with a MeshGradientPainter installed via
Modifier.paint.
Material 3 dependency and component changes
- Material 3 no longer brings in
material-icons-core. Declare it explicitly
only when maintaining existing icons; prefer Material Symbols vector XML.
- Stable Material 3 excludes expressive and component-override APIs that still
carried their experimental annotations. Use a compatible artifact line when
those APIs are required.
TabRow and ScrollableTabRow are deprecated; select the appropriate
primary or secondary variant.
- Custom
ColorScheme construction must supply fixed roles and surface
container roles.
High-Value APIs
Observe placement and visibility precisely
Use Modifier.onLayoutRectChanged for debounced or throttled root-, window-,
or screen-relative bounds. Use onVisibilityChanged for visibility state;
onFirstVisible was deprecated because it could fire after every re-entry.
Custom nodes can use onVisibilityChangedNode().
Build advanced layouts
Modifier.animateBounds animates lookahead size and position. FlexBox
provides grow, shrink, wrapping, direction, and alignment. Experimental Grid
provides explicit two-dimensional tracks and placement. Stable lazy-layout
primitives support custom measure policies and internally scheduled prefetch.
Handle modern scrolling
Use scrollable2D for two-axis motion, scrollableArea() for scrolling plus
bounds clipping, and ScrollIndicatorState or Modifier.scrollIndicator for
indicator integrations. An OverscrollEffect can separate event handling from
drawing, but the same effect must never be drawn twice.
Choose the right persistence lifetime
remember: composition lifetime.
retain: survives temporary hierarchy removal without serialization.
rememberSaveable or rememberSerializable: state restoration with
supported saved-state encoding.
Check key lifetime, registry ownership, Android parcelability, and disposal
requirements in Setup, Runtime, and State.
Host Compose beyond a standard activity
ComposeViewContext can compose an unattached ComposeView. Dialogs and
popups can receive custom window tokens, and window types enable service-owned
overlay hosts. Treat these as Android platform integration and verify token,
lifecycle, and permission ownership.
Test deterministically
The v2 Compose UI test APIs use StandardTestDispatcher by default. Advance
their shared scheduler explicitly, such as with runCurrent(). Older test APIs
retain unconfined behavior unless an effectContext variant is configured.
Use onRootWithViewInteraction to scope node lookup inside one View hierarchy
in hybrid interfaces.
Upgrade Checklist
- Resolve actual artifact versions and BOM constraints.
- Verify
minSdk, compileSdk, AGP, Kotlin, and lint compatibility.
- Search for removed behavior-flag assignments and deprecated overloads.
- Check
LocalIndication, saveable-state keys, retained-store installation,
and pausable-composition disposal.
- Review focus clearing, insets consumption, window rulers, and host tokens.
- Re-run semantics tests without relying on an exact incidental tree shape.
- Advance queued test coroutines when using standard-dispatcher test APIs.
- Test API-level fallbacks for fonts, wide-gamut graphics, credential requests,
date types, and Android-only properties.
- Confirm overscroll and modifier-node drawing occurs exactly once.
- Prefer direct node tags, state-backed text/component APIs, and explicit
lifecycle ownership in new code.
1---2name: jetpack-compose-knowledge-patch-23description: Jetpack Compose4license: MIT5---678# Jetpack Compose910Use this skill when implementing, upgrading, reviewing, or testing AndroidX11Compose UI, Foundation, Runtime, Material 3, compiler-plugin, or BOM code.12Treat those artifacts as separately versioned products: inspect the module's13Gradle declarations, version catalog, and resolved dependency graph before14applying guidance.1516## Working Method17181. Identify the affected surface: build setup, runtime/state, input and focus,19 layout/graphics, text, Material 3, Android hosting, or testing.202. Check the resolved version of every relevant artifact. A BOM aligns the21 artifacts it manages but does not make every Compose-related product share22 one release number.233. Search the topic reference below for renamed, removed, or behavior-changing24 APIs before editing call sites.254. Prefer the replacement API over compatibility flags. Several migration26 flags existed briefly and were removed in later releases.275. Compile the affected source set, run Compose lint, and exercise UI tests on28 the scheduler and host configuration used by the project.296. For Android-only behavior, verify API-level guards, window ownership,30 insets, resources, and View/Compose interop rather than assuming common-code31 behavior applies unchanged.3233## Topic Index3435| Reference | Topics |36| --- | --- |37| [Setup, Runtime, and State](references/setup-runtime-state.md) | Toolchain floors, BOMs, compiler reports, pausable composition, retained and saveable state, diagnostics |38| [Input, Scrolling, and Focus](references/input-scroll-focus.md) | Focus, pointer and trackpad input, haptics, overscroll, scrolling, visibility callbacks, indicators |39| [Layout, Animation, and Graphics](references/layout-animation-graphics.md) | Lookahead, shared transitions, FlexBox/Grid, lazy infrastructure, modifier nodes, shadows, shaders, mesh gradients |40| [Text, Autofill, and Resources](references/text-autofill-resources.md) | Text fields, autosizing, annotations, autofill, selection, fonts, resources, clipboard |41| [Material 3 Components](references/material3-components.md) | Component migrations, state APIs, navigation, pickers, tooltips, sheets, sliders, color and inset changes |42| [Platform, Window, and Interop](references/platform-window-interop.md) | Insets, window geometry, ComposeView hosting, dialogs/popups, paint and color interop, frame rate |43| [Semantics, Accessibility, and Testing](references/semantics-accessibility-testing.md) | Semantics tree changes, accessibility, test artifacts, schedulers, hybrid UI scoping |4445## Breaking Changes First4647### Toolchain and platform floors4849- Compose Animation, Foundation, Runtime, and UI require Android API 23 or50 newer from 1.10.0.51- Artifacts built with Kotlin 2.0 require Kotlin Gradle Plugin 2.0.0 or newer.52- Compose 1.12 Android builds require `compileSdk = 37` and Android Gradle53 Plugin 9; `targetSdk` remains an independent choice.54- Compose lint from 1.9.0 requires AGP 8.8.2 or standalone Lint 8.8.2 and an55 Android Studio Ladybug-era toolchain or newer.5657See [Setup, Runtime, and State](references/setup-runtime-state.md) before an58upgrade changes the build.5960### Indication migration6162After recompiling against 1.9.0, interaction modifiers whose overload omits an63explicit `Indication` require `LocalIndication` to provide an64`IndicationNodeFactory`. A legacy `Indication` can fail at runtime. Migrate the65implementation or use an explicit-indication overload while bridging. The66temporary `isNonComposedClickableEnabled` escape hatch is absent from 1.10.0.6768### State and lifecycle changes6970- Remove custom keys from `rememberSaveable`; positional scoping is now the71 supported behavior.72- A cancelled `PausableComposition` must be disposed and cannot be reused.73- Install custom retained-value stores with74 `LocalRetainedValuesStoreProvider`; do not provide the local directly.75- `retain` keeps values across temporary hierarchy removal without76 serialization. Do not retain keys or values that can leak resources; mark77 unsuitable types with `@DoNotRetain`.7879### Semantics and test structure8081`background`, `border`, and `graphicsLayer` can add semantics nodes. Tests that82assert exact parent/child/sibling structure are brittle; tag the intended node83or use an ancestor matcher. Replace `invisibleToUser()` with84`hideFromAccessibility()`, and retrieve a semantics ID through85`fetchSemanticsNode().id`.8687### Text and autofill migrations8889- Replace `AutoSize` with `TextAutoSize`.90- Replace deprecated autofill APIs with semantic `fillableData` and91 `onFillData`; text autofill needs matching UI and Foundation support.92- `TextFieldState.edit {}` creates an undo entry. Explicitly call93 `undoState.clearHistory()` when programmatic edits should reset history.94- Use `OutputTransformation` plus `TextFieldBuffer.addStyle`; the interim95 `AnnotatedOutputTransformation` API is gone.9697### Layout and animation removals9899- Replace deprecated contextual flow layouts and overflow overloads with100 ordinary `FlowRow`/`FlowColumn` or a custom layout.101- Replace `ScaleToBounds` with `scaleToBounds`; removed shared-transition102 factories and parameters have no direct compatibility flag.103- Replace `Modifier.meshGradient` with a `MeshGradientPainter` installed via104 `Modifier.paint`.105106### Material 3 dependency and component changes107108- Material 3 no longer brings in `material-icons-core`. Declare it explicitly109 only when maintaining existing icons; prefer Material Symbols vector XML.110- Stable Material 3 excludes expressive and component-override APIs that still111 carried their experimental annotations. Use a compatible artifact line when112 those APIs are required.113- `TabRow` and `ScrollableTabRow` are deprecated; select the appropriate114 primary or secondary variant.115- Custom `ColorScheme` construction must supply fixed roles and surface116 container roles.117118## High-Value APIs119120### Observe placement and visibility precisely121122Use `Modifier.onLayoutRectChanged` for debounced or throttled root-, window-,123or screen-relative bounds. Use `onVisibilityChanged` for visibility state;124`onFirstVisible` was deprecated because it could fire after every re-entry.125Custom nodes can use `onVisibilityChangedNode()`.126127### Build advanced layouts128129`Modifier.animateBounds` animates lookahead size and position. `FlexBox`130provides grow, shrink, wrapping, direction, and alignment. Experimental `Grid`131provides explicit two-dimensional tracks and placement. Stable lazy-layout132primitives support custom measure policies and internally scheduled prefetch.133134### Handle modern scrolling135136Use `scrollable2D` for two-axis motion, `scrollableArea()` for scrolling plus137bounds clipping, and `ScrollIndicatorState` or `Modifier.scrollIndicator` for138indicator integrations. An `OverscrollEffect` can separate event handling from139drawing, but the same effect must never be drawn twice.140141### Choose the right persistence lifetime142143- `remember`: composition lifetime.144- `retain`: survives temporary hierarchy removal without serialization.145- `rememberSaveable` or `rememberSerializable`: state restoration with146 supported saved-state encoding.147148Check key lifetime, registry ownership, Android parcelability, and disposal149requirements in [Setup, Runtime, and State](references/setup-runtime-state.md).150151### Host Compose beyond a standard activity152153`ComposeViewContext` can compose an unattached `ComposeView`. Dialogs and154popups can receive custom window tokens, and window types enable service-owned155overlay hosts. Treat these as Android platform integration and verify token,156lifecycle, and permission ownership.157158### Test deterministically159160The v2 Compose UI test APIs use `StandardTestDispatcher` by default. Advance161their shared scheduler explicitly, such as with `runCurrent()`. Older test APIs162retain unconfined behavior unless an `effectContext` variant is configured.163Use `onRootWithViewInteraction` to scope node lookup inside one View hierarchy164in hybrid interfaces.165166## Upgrade Checklist167168- Resolve actual artifact versions and BOM constraints.169- Verify `minSdk`, `compileSdk`, AGP, Kotlin, and lint compatibility.170- Search for removed behavior-flag assignments and deprecated overloads.171- Check `LocalIndication`, saveable-state keys, retained-store installation,172 and pausable-composition disposal.173- Review focus clearing, insets consumption, window rulers, and host tokens.174- Re-run semantics tests without relying on an exact incidental tree shape.175- Advance queued test coroutines when using standard-dispatcher test APIs.176- Test API-level fallbacks for fonts, wide-gamut graphics, credential requests,177 date types, and Android-only properties.178- Confirm overscroll and modifier-node drawing occurs exactly once.179- Prefer direct node tags, state-backed text/component APIs, and explicit180 lifecycle ownership in new code.