AGENTS.android.md โ Android / Jetpack Compose
Additive to ../AGENTS.md and AGENTS.kotlin.md. Android-specific rules only.
Build and check
./gradlew ktlintCheck detekt # must pass
./gradlew :feature:<module>:testDebugUnitTest
./gradlew assembleDebug # only if you touched build config
Jetpack Compose rules
- Composables are stateless and take a state object plus lambdas. Hoist state to the ViewModel.
- No business logic, no
LaunchedEffectdoing network calls, in a Composable. - Collect ViewModel flows with
collectAsStateWithLifecycle(), notcollectAsState(). - Every new component in
core/designsystemneeds a@Previewand must consume design tokens, never hardcodedColor(0xFF...)ordpvalues that duplicate a token. - Use existing components before adding a new one. If you add one, note in the PR which existing component you considered and why it did not fit.
Modifieris always the first optional parameter and is passed through.- User-facing text comes from string resources, never literals. Icons that act
get a
contentDescription; decorative ones getnull. - New navigation destinations use type-safe
@Serializableroutes, not strings.
Android rules
- A ViewModel exposes one
StateFlow<UiState>. NoLiveDatain new code. - No
Activity,FragmentorViewcontext held in a ViewModel or singleton. If you need aContext, inject the application context. - Views collect flows inside
repeatOnLifecycle, never in a barelifecycleScope.launch. - A new permission in
AndroidManifest.xmlneeds a stated reason in the PR.
Testing
- Paparazzi or screenshot tests for design system components. Compose UI tests
(
createComposeRule) for interaction. - Kotlin testing rules, including the bug-fix rule, are in
AGENTS.kotlin.md.
Anti-patterns seen in this repo
- Mixed
Flow/LiveDatain the same feature. New code isFlow. - Blocking calls inside
init {}of a ViewModel.