Skip to content

Android

Scope: native Android apps in Kotlin, including Jetpack Compose.

Entries are sorted by score from 1 to 10 (criteria): 9โ€“10 start here or strongly recommended, 6โ€“8 recommended, 1โ€“5 further reading or conditional.

Adopted references

Google's official architecture guidance is comprehensive. Follow it as-is. This file only highlights the core rules.

Key rules

Architecture

Accessibility

  • 7 ANDROID-9 Make every screen usable with TalkBack and Switch Access: describe each meaningful image and icon with a contentDescription, pass null for decorative ones, expose the role and state of custom components through Compose semantics, and make each touch target at least 48dp by 48dp. Material components such as Button and IconButton already have the minimum size and built-in semantics, but custom elements need both set by hand; scan each screen with the Accessibility Scanner app as well. This applies A11Y-9 and A11Y-10. (Android, Make apps more accessible, Compose, Semantics, Android, Test your app's accessibility)
  • 6 ANDROID-10 Set text sizes in sp, and test every screen at the largest font size, which is 200% since Android 14, so that text follows the user's setting without being cut off. Don't use sp for padding or fixed heights, and convert between sp and pixels with TypedValue.applyDimension() and TypedValue.deriveDimension() instead of calculating with fontScale, because the scaling is nonlinear. This applies A11Y-12. (Android 14, Non-linear font scaling to 200%)

How to enforce

Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.

  • 6 Konsist, architecture assertions: Kotlin tests that check which layers may depend on which; set the direction to match the Android guide. Its Android snippets also check that ViewModel properties are Flows and that repositories live in a repository package. Partly checks ANDROID-1, ANDROID-3 and ANDROID-4.
  • 6 Compose accessibility checks: with the ui-test-junit4-accessibility dependency, enableAccessibilityChecks() on the AndroidComposeTestRule runs the Accessibility Test Framework on each test action and fails the test on missing labels, small touch targets, low contrast and traversal order problems. For Views, Espresso's AccessibilityChecks.enable() runs the same checks. Partly checks ANDROID-9.
  • 5 detekt, coroutines rules: InjectDispatcher flags hard-coded dispatchers, following the same Android best-practices page. Partly checks ANDROID-6.
  • 5 Android Lint, ContentDescription: flags images and image buttons without a contentDescription in layout files, and SpUsage flags text sizes in dp. Both check XML layouts only, not Compose code. Partly checks ANDROID-9 and ANDROID-10.
  • 4 Slack compose-lints: Android Lint checks for Jetpack Compose. ComposeViewModelForwarding flags ViewModels passed down the UI tree, which breaks unidirectional data flow. Partly checks ANDROID-2.
  • 4 Module Graph Assert: a Gradle plugin that fails the build when a module depends on one it isn't allowed to. It guards the module structure but doesn't create it. Partly checks ANDROID-8.

Tutorials and further reading