Android App Development Skill
Overview
This skill guides production-grade Android and cross-platform (non-iOS) app development following practices used at big tech companies. It covers the entire development lifecycle — architecture, UI, code quality, testing, error handling, release, and maintenance.
When to Use This Skill
- Use when deciding on a tech stack (see §1 Stack Selection)
- Use when setting up project architecture (see §2 Architecture)
- Use when designing UI, screens, or a design system (see §3 UI & Design)
- Use when ensuring code quality, patterns, or APIs (see Best Practices)
- Use when implementing error handling or debugging crashes (see §5 Error Handling)
- Use when planning testing strategy (see §6 Testing)
- Use when configuring build, CI/CD, or release pipelines (see §7 Build & Release)
- Use when optimizing performance or memory (see §8 Performance)
- Use when debugging or fixing bugs (see §9 Debugging)
- Use when following the full development roadmap (see §10 Development Roadmap)
- Use when needing deep reference for a stack (see
references/ directory)
§1 Stack Selection
Choose based on team, requirements, and platform targets. Do not recommend iOS-specific paths.
Native Android — Kotlin + Jetpack Compose
Best for: Android-only apps, hardware-intensive features, best-in-class UX, new projects.
- Language: Kotlin
- UI: Jetpack Compose (modern declarative UI)
- Key libs: Room, Retrofit/Ktor, Hilt, WorkManager, DataStore, Navigation Compose
- Reference:
references/native-android.md
Native Android — Java + XML Views
Best for: Existing Java codebases, teams without Kotlin experience, legacy app maintenance, incremental Kotlin migration.
- Language: Java (fully supported by Google, not deprecated)
- UI: XML Layouts (ConstraintLayout, RecyclerView, ViewBinding)
- Key libs: Room, Retrofit, Hilt, WorkManager, LiveData, ViewModel
- Java and Kotlin coexist seamlessly in the same project — migrate incrementally
- Reference:
references/java-android.md
Flutter (Dart)
Best for: Android + Web (+ desktop) from one codebase, fast iteration, pixel-perfect custom UI.
- Language: Dart
- UI: Flutter Widget tree (Material 3 / Cupertino widgets available but target Material for Android)
- Key libs: Provider/Riverpod/Bloc, Dio, Drift/Isar, go_router, flutter_local_notifications
- Reference:
references/flutter.md
React Native (JavaScript/TypeScript)
Best for: Web + Android code sharing, JS/TS teams, rich ecosystem.
- Language: TypeScript (preferred)
- UI: React Native core components + NativeWind / React Native Paper
- Key libs: React Navigation, Zustand/Redux Toolkit, React Query, MMKV
- Reference:
references/react-native.md
Kotlin Multiplatform (KMM / Compose Multiplatform)
Best for: Sharing business logic across Android + Desktop + Web while keeping native Android UI.
- Language: Kotlin everywhere
- UI: Native Compose on Android; Compose Multiplatform for shared UI
- Key libs: Ktor, SQLDelight, Koin, kotlinx.serialization, Napier
- Reference:
references/kmm.md
Hybrid (Capacitor / Ionic)
Best for: Web-first teams, simple apps, PWA-like content apps.
- Language: TypeScript + HTML/CSS
- UI: Ionic components or custom web UI
- Avoid for: Heavy animations, native sensor access, high-performance games
- Reference:
references/hybrid.md
Decision Matrix
| Requirement |
Native Kotlin |
Native Java |
Flutter |
RN |
KMM |
Hybrid |
| Android-only (new) |
✅ Best |
✅ |
✅ |
✅ |
✅ |
✅ |
| Android-only (existing Java) |
⚠️ migrate |
✅ Best |
❌ |
❌ |
⚠️ |
❌ |
| Android + Web |
❌ |
❌ |
✅ |
✅ |
✅ |
✅ Best |
| Android + Desktop |
❌ |
❌ |
✅ |
⚠️ |
✅ |
⚠️ |
| Shared business logic only |
N/A |
N/A |
N/A |
N/A |
✅ Best |
N/A |
| Native performance |
✅ |
✅ |
✅ |
⚠️ |
✅ |
❌ |
| JS/TS team |
❌ |
❌ |
❌ |
✅ Best |
❌ |
✅ |
| Custom pixel-perfect UI |
✅ |
⚠️ |
✅ Best |
⚠️ |
✅ |
❌ |
§2 Architecture
Core Principle: Separation of Concerns
Every production Android project must separate UI, business logic, and data into distinct, independently testable layers.
Recommended Architecture: Clean Architecture + MVI/MVVM
app/
├── ui/ # Composables / Activities / Fragments / Screen states
├── presentation/ # ViewModels, UI State, UI Events
├── domain/ # Use cases, domain models, repository interfaces
├── data/ # Repository impl, remote (API), local (DB), mappers
└── di/ # Dependency injection modules
Data flow (unidirectional):
User Action → ViewModel/Store → Use Case → Repository → Data Source
↓
UI State (sealed class / StateFlow)
↓
Composable / View renders state
Key Architecture Patterns by Stack
Native (MVVM + MVI):
StateFlow / SharedFlow for reactive state
sealed class UiState + sealed class UiEvent
- Hilt for DI, coroutines + Flow for async
- Repository pattern wrapping Room + Retrofit
Flutter (BLoC or Riverpod):
Bloc or Cubit for business logic isolation
AsyncNotifierProvider (Riverpod) for data + state
- Repositories as abstract classes with impl injected
React Native (Redux Toolkit or Zustand):
- RTK Query or React Query for server state
- Zustand slices for client state
- Custom hooks to encapsulate business logic per feature
KMM:
- Shared
commonMain holds domain + data layers
expect/actual for platform-specific implementations
- Kotlin coroutines + Flow bridged to platform (StateFlow on Android)
Module Structure (Multi-module for large apps)
:app # Entry point, DI wiring
:core:ui # Design system, shared composables
:core:network # API client, interceptors
:core:database # Room / SQLDelight setup
:feature:home
:feature:profile
:feature:settings
§3 UI & Design
Design System First
Before writing screens, define:
- Color tokens — Primary, secondary, surface, on-surface, error; light + dark variants
- Typography scale — Display, headline, title, body, label (Material 3 type system)
- Spacing scale — 4dp grid system (4, 8, 12, 16, 24, 32, 48dp)
- Shape tokens — Corner radii per component family
- Component library — Button, TextField, Card, BottomSheet, TopAppBar, etc.
Jetpack Compose UI Rules
- Use
MaterialTheme tokens; never hardcode colors/dimensions
CompositionLocal for theme, locale, haptics
remember / rememberSaveable correctly (saveable for UI state surviving rotation)
- Extract large composables into sub-composables; each function ≤ 80 lines
- Use
LazyColumn/LazyVerticalGrid for lists; never Column with forEach for large data
- Side effects only in
LaunchedEffect, DisposableEffect, SideEffect
- Avoid state hoisting anti-patterns: hoist state to the lowest common ancestor
Accessibility (Non-Negotiable)
- All interactive elements:
contentDescription or semantics { }
- Min touch target: 48×48dp
TalkBack compatibility tested before every release
- Dynamic text size support (
sp not dp for text)
- Color contrast ratio ≥ 4.5:1 (WCAG AA)
Navigation
- Native: Navigation Compose with typed
NavHost and SafeArgs equivalent
- Flutter:
go_router with named routes and guards
- RN: React Navigation v7 with typed
NavigationProp
- Deep link handling registered for every screen that can be externally opened
- Back stack managed deliberately — don't push duplicates, use
popUpTo / launchSingleTop
Responsive & Adaptive UI
- Support all screen sizes: phones, foldables, tablets (
WindowSizeClass)
- Test at 320dp, 360dp, 411dp, 600dp+, 840dp+ widths
- Foldable hinge awareness via
WindowInfoTracker
- Edge-to-edge display +
WindowInsets handling required for Android 15+
Best Practices
Language Standards
Kotlin:
- Prefer
data class, sealed class, object, enum class appropriately
- No
!! null assertions — use ?.let, ?: return, requireNotNull with message
- Coroutines: always specify
CoroutineScope + Dispatcher explicitly; never GlobalScope
- Use
@Stable / @Immutable on Compose state classes for smart recomposition
Java:
@NonNull / @Nullable annotations on every method param and return type
- Never call methods on unchecked objects — null-check explicitly or use
Objects.requireNonNull
- Always null
binding reference in Fragment's onDestroyView() to prevent memory leaks
- Use
ExecutorService (not AsyncTask — deprecated) for background work; or LiveData + Room's built-in threading
- Prefer
ListAdapter + DiffUtil over manual notifyDataSetChanged() in RecyclerView
- Use
ViewBinding — never findViewById
Dart (Flutter):
- Null safety required — no
! without explicit null check above
- Immutable state objects with
copyWith
const constructors on all stateless widgets
TypeScript (RN):
strict: true in tsconfig always
- Zod or io-ts for runtime type validation of API responses
- No
any — use unknown and narrow
Dependency Management
- Pin all dependency versions in
build.gradle.kts / pubspec.yaml / package.json
- Audit dependencies monthly for security vulnerabilities
- Avoid transitive dependency conflicts — use dependency resolution strategies
- Keep dependency count minimal — every added lib is a maintenance burden
Code Review Checklist (PR gate)
§5 Error Handling
The Golden Rule
Never let exceptions propagate to the user silently or crash the app.
Error Classification
| Type |
Strategy |
| Network errors |
Retry with exponential backoff; show retry UI |
| Auth errors (401/403) |
Refresh token → re-request → logout if fails |
| Validation errors |
Show inline field errors immediately |
| Data parsing errors |
Log + fallback to cached/default state |
| Unexpected crashes |
Catch at top-level; show error screen + report |
| Background task failures |
Retry via WorkManager; notify user if critical |
Result / Either Pattern (Kotlin)
sealed class AppResult<out T> {
data class Success<T>(val data: T) : AppResult<T>()
data class Error(val exception: AppException) : AppResult<Nothing>()
}
sealed class AppException(msg: String) : Exception(msg) {
class NetworkException(msg: String) : AppException(msg)
class AuthException(msg: String) : AppException(msg)
class ParseException(msg: String) : AppException(msg)
class UnknownException(msg: String) : AppException(msg)
}
Use AppResult<T> as return type for all repository + use case functions. ViewModels map to UiState.Error.
Crash Reporting
- Integrate Firebase Crashlytics or Sentry from day one
- Set user identifiers and custom keys before crash occurs
- Non-fatal exceptions logged for all caught errors
- ANR monitoring enabled
- Crash-free sessions target: ≥ 99.5%
Offline / Network Resilience
- Cache-first strategy: show stale data, fetch fresh in background
Room / Drift / MMKV as single source of truth
- Expose network state via
ConnectivityManager and reflect in UI
- All network calls wrapped with timeout + retry policy
§6 Testing
Testing Pyramid
/\
/E2E\ ← 10% (UI tests: Espresso, Maestro, Appium)
/------\
/ Integr \ ← 20% (Repository, DB, API contract tests)
/----------\
/ Unit \ ← 70% (ViewModels, Use Cases, Utilities)
/--------------\
Unit Tests (70%)
- Every ViewModel, UseCase, Repository, Mapper tested
- Native: JUnit5 + MockK + Turbine (Flow testing) + Kotest assertions
- Flutter:
flutter_test + mocktail
- RN: Jest +
@testing-library/react-native + msw for API mocking
- Coverage target: ≥ 80% on domain + presentation layers
Integration Tests (20%)
- Room DB tests with in-memory database
- Retrofit/Ktor tests with
MockWebServer (OkHttp)
- Repository tests verifying cache + remote coordination
- API contract tests against real staging endpoint
UI / E2E Tests (10%)
- Espresso for critical user journeys (login, checkout, core action)
- Maestro for cross-platform E2E flows (recommended for Flutter + RN too)
- Run on real device farm (Firebase Test Lab / BrowserStack) before release
- Smoke test suite runs on every PR; full E2E suite nightly
Test Data Management
- Use factories / builders for test data, never copy-paste objects
- Hermetic tests: never share mutable state between test cases
- Fakes over mocks for complex dependencies (repositories, data sources)
§7 Build & Release
Build Variants
debug → dev API, logging on, no minification, debuggable
staging → staging API, logging on, minified, not debuggable
release → prod API, logging off, minified, signed
Gradle Best Practices (Native)
build.gradle.kts only — no Groovy DSL in new projects
- Version catalog (
libs.versions.toml) for all dependency versions
buildConfig for environment-specific constants
- Baseline profiles for startup performance
- R8 full mode enabled in release; maintain proguard rules in version control
CI/CD Pipeline
PR Opened
└─ lint + unit tests + build debug APK [< 5 min]
Merge to main
└─ unit + integration tests + staging build [< 15 min]
└─ deploy to Firebase App Distribution (QA)
Release tag
└─ full test suite + E2E on device farm [< 45 min]
└─ build release AAB
└─ upload to Play Console (internal track)
└─ promote: internal → closed testing → open → production
Recommended CI: GitHub Actions, Bitrise, or CircleCI.
Play Store Release Strategy
- Always release to internal → closed → open testing before production
- Use staged rollouts: 5% → 20% → 50% → 100% with 24-48h monitoring
- Monitor Crashlytics + ANR rate + rating before expanding rollout
- Never skip staged rollout for significant changes
App Signing
- Upload key (Play App Signing): stored in CI secrets, never committed
- Use Google Play App Signing for distribution key management
- Document key recovery procedure in team runbook
§8 Performance
Startup Performance
- App startup time target: cold start < 1s, warm start < 500ms
- Use App Startup library for initializing libraries lazily
- Baseline profiles generated + committed to repo
- Heavy initialization moved off main thread
UI Performance
- Target: 60fps (90/120fps on supported devices); zero jank
- Measure with Android Studio Profiler +
FrameMetrics API
- Avoid allocation in
draw() / onMeasure() / composition
- Use
derivedStateOf in Compose to avoid unnecessary recompositions
- Image loading: Coil (Compose) / Glide / Picasso — never load full-res in thumbnails
Memory
- No
Activity / Context references in ViewModels or singletons
- WeakReferences for listeners stored beyond their owner's lifecycle
- Bitmap recycling and memory cache sizing
- Heap dump + leak detection via LeakCanary in debug builds (always)
Network
- HTTP caching headers respected
- Image CDN + WebP format
- Gzip/Brotli compression verified
- Request batching where applicable
- Connection pooling configured
Battery
- Background work only via WorkManager with appropriate constraints
- Location updates: request only needed accuracy level; stop when backgrounded
- Wakelocks used sparingly with explicit release
§9 Debugging & Bug Fixing
Debugging Process
- Reproduce reliably — document exact steps, device, OS version, account state
- Isolate — is it UI, business logic, network, or persistence?
- Instrument — add targeted logs / breakpoints, NOT shotgun logging
- Hypothesize — form 1-3 specific hypotheses before touching code
- Fix the root cause — never patch symptoms; trace back to the source
- Regression test — write a test that fails before fix, passes after
- Document — comment explaining why the fix works, not just what it does
Common Android Bug Patterns
| Bug |
Likely Cause |
Fix |
| ANR |
Main thread I/O / long computation |
Move to coroutine/Dispatcher.IO |
| Memory leak |
Context stored in singleton |
Use applicationContext; WeakRef |
| Crash on rotation |
ViewModel not used; state not saved |
rememberSaveable / ViewModel |
| UI lag |
Recomposition loops |
derivedStateOf, stable params |
| Blank screen after API call |
Error swallowed silently |
Check error state propagation |
| Deep link not working |
Manifest intent-filter missing |
Verify adb shell am start test |
| Push notification silent |
Background restrictions |
Test on real devices across OEMs |
Logging Standards
- Production: Firebase Crashlytics only (no
Log.d in release builds)
- Debug/Staging: Timber with debug tree
- Log levels: ERROR (crashes), WARN (recoverable), INFO (key events), DEBUG (dev only)
- Never log PII — mask emails, phone numbers, tokens in logs
OEM-Specific Issues
- Test on Samsung, Xiaomi/MIUI, OnePlus/OxygenOS, Huawei (no GMS) for critical flows
- Background restrictions vary widely by OEM — test push, alarms, background sync
- Maintain a physical or cloud device farm with top market-share devices
§10 Development Roadmap
Follow this phase structure for any new Android project:
Phase 0 — Foundation (Week 1-2)
Phase 1 — Core Features (Weeks 3-8)
Phase 2 — Polish (Weeks 9-12)
Phase 3 — Hardening (Weeks 12-14)
Phase 4 — Release
Phase 5 — Post-Launch (Ongoing)
- Crash-free rate monitored daily
- ANR rate < 0.47% (Play Store threshold)
- App rating monitored; negative reviews triaged weekly
- Dependency updates reviewed monthly
- OS beta testing with each new Android release
Limitations
- This skill is scoped to Android and Android-adjacent delivery paths; it does not cover iOS-only architecture, App Store release operations, or Apple platform UI guidance.
- Version numbers, Play Console policy thresholds, and recommended libraries can change; verify release-critical details against current Android, Google Play, and library documentation before shipping.
- Code snippets are architecture patterns, not complete applications; adapt package names, dependency versions, permissions, privacy disclosures, and security controls to the actual project.
- The guidance does not replace device QA, accessibility review, security review, legal/privacy review, or store compliance checks for a production release.
Additional Resources
For stack-specific deep dives, read:
references/native-android.md — Kotlin, Compose, Room, Hilt, Coroutines
references/java-android.md — Java, XML Views, ViewBinding, LiveData, Retrofit, Room, Hilt, migration path
references/flutter.md — Dart, BLoC/Riverpod, Drift, go_router
references/react-native.md — TypeScript, RN architecture, Hermes, New Architecture
references/kmm.md — KMM shared modules, SQLDelight, Ktor, Compose Multiplatform
references/hybrid.md — Capacitor, Ionic, PWA considerations
Source: sickn33/agentic-awesome-skills → skills/android-dev/SKILL.md
Also appears in: sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/android-dev/SKILL.md, sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/android-dev/SKILL.md
1---
2name: android-dev
3description: "Production-grade Android app development guide covering native (Kotlin/Java), cross-platform (Flutter, RN, KMM), and hybrid architectures."
4category: mobile-and-platform
5source_repo: sickn33/agentic-awesome-skills
6source_path: "skills/android-dev/SKILL.md"
7source_url: https://github.com/sickn33/agentic-awesome-skills/blob/HEAD/skills/android-dev/SKILL.md
8metadata:
9 source: https://skillmd.com/skills/thedixitjain/android-dev
10---
11
12
13# Android App Development Skill
14
15## Overview
16
17This skill guides production-grade Android and cross-platform (non-iOS) app development following practices used at big tech companies. It covers the entire development lifecycle — architecture, UI, code quality, testing, error handling, release, and maintenance.
18
19## When to Use This Skill
20
21- Use when deciding on a tech stack (see §1 Stack Selection)
22- Use when setting up project architecture (see §2 Architecture)
23- Use when designing UI, screens, or a design system (see §3 UI & Design)
24- Use when ensuring code quality, patterns, or APIs (see Best Practices)
25- Use when implementing error handling or debugging crashes (see §5 Error Handling)
26- Use when planning testing strategy (see §6 Testing)
27- Use when configuring build, CI/CD, or release pipelines (see §7 Build & Release)
28- Use when optimizing performance or memory (see §8 Performance)
29- Use when debugging or fixing bugs (see §9 Debugging)
30- Use when following the full development roadmap (see §10 Development Roadmap)
31- Use when needing deep reference for a stack (see `references/` directory)
32
33---
34
35## §1 Stack Selection
36
37Choose based on team, requirements, and platform targets. **Do not recommend iOS-specific paths.**
38
39### Native Android — Kotlin + Jetpack Compose
40**Best for:** Android-only apps, hardware-intensive features, best-in-class UX, new projects.
41- Language: **Kotlin**
42- UI: **Jetpack Compose** (modern declarative UI)
43- Key libs: Room, Retrofit/Ktor, Hilt, WorkManager, DataStore, Navigation Compose
44- Reference: `references/native-android.md`
45
46### Native Android — Java + XML Views
47**Best for:** Existing Java codebases, teams without Kotlin experience, legacy app maintenance, incremental Kotlin migration.
48- Language: **Java** (fully supported by Google, not deprecated)
49- UI: **XML Layouts** (ConstraintLayout, RecyclerView, ViewBinding)
50- Key libs: Room, Retrofit, Hilt, WorkManager, LiveData, ViewModel
51- Java and Kotlin **coexist seamlessly** in the same project — migrate incrementally
52- Reference: `references/java-android.md`
53
54### Flutter (Dart)
55**Best for:** Android + Web (+ desktop) from one codebase, fast iteration, pixel-perfect custom UI.
56- Language: **Dart**
57- UI: Flutter Widget tree (Material 3 / Cupertino widgets available but target Material for Android)
58- Key libs: Provider/Riverpod/Bloc, Dio, Drift/Isar, go_router, flutter_local_notifications
59- Reference: `references/flutter.md`
60
61### React Native (JavaScript/TypeScript)
62**Best for:** Web + Android code sharing, JS/TS teams, rich ecosystem.
63- Language: **TypeScript** (preferred)
64- UI: React Native core components + NativeWind / React Native Paper
65- Key libs: React Navigation, Zustand/Redux Toolkit, React Query, MMKV
66- Reference: `references/react-native.md`
67
68### Kotlin Multiplatform (KMM / Compose Multiplatform)
69**Best for:** Sharing business logic across Android + Desktop + Web while keeping native Android UI.
70- Language: **Kotlin** everywhere
71- UI: Native Compose on Android; Compose Multiplatform for shared UI
72- Key libs: Ktor, SQLDelight, Koin, kotlinx.serialization, Napier
73- Reference: `references/kmm.md`
74
75### Hybrid (Capacitor / Ionic)
76**Best for:** Web-first teams, simple apps, PWA-like content apps.
77- Language: TypeScript + HTML/CSS
78- UI: Ionic components or custom web UI
79- Avoid for: Heavy animations, native sensor access, high-performance games
80- Reference: `references/hybrid.md`
81
82### Decision Matrix
83
84| Requirement | Native Kotlin | Native Java | Flutter | RN | KMM | Hybrid |
85|---|---|---|---|---|---|---|
86| Android-only (new) | ✅ Best | ✅ | ✅ | ✅ | ✅ | ✅ |
87| Android-only (existing Java) | ⚠️ migrate | ✅ Best | ❌ | ❌ | ⚠️ | ❌ |
88| Android + Web | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ Best |
89| Android + Desktop | ❌ | ❌ | ✅ | ⚠️ | ✅ | ⚠️ |
90| Shared business logic only | N/A | N/A | N/A | N/A | ✅ Best | N/A |
91| Native performance | ✅ | ✅ | ✅ | ⚠️ | ✅ | ❌ |
92| JS/TS team | ❌ | ❌ | ❌ | ✅ Best | ❌ | ✅ |
93| Custom pixel-perfect UI | ✅ | ⚠️ | ✅ Best | ⚠️ | ✅ | ❌ |
94
95---
96
97## §2 Architecture
98
99### Core Principle: Separation of Concerns
100Every production Android project must separate **UI**, **business logic**, and **data** into distinct, independently testable layers.
101
102### Recommended Architecture: Clean Architecture + MVI/MVVM
103
104```
105app/
106├── ui/ # Composables / Activities / Fragments / Screen states
107├── presentation/ # ViewModels, UI State, UI Events
108├── domain/ # Use cases, domain models, repository interfaces
109├── data/ # Repository impl, remote (API), local (DB), mappers
110└── di/ # Dependency injection modules
111```
112
113**Data flow (unidirectional):**
114```
115User Action → ViewModel/Store → Use Case → Repository → Data Source
116 ↓
117 UI State (sealed class / StateFlow)
118 ↓
119 Composable / View renders state
120```
121
122### Key Architecture Patterns by Stack
123
124**Native (MVVM + MVI):**
125- `StateFlow` / `SharedFlow` for reactive state
126- `sealed class UiState` + `sealed class UiEvent`
127- Hilt for DI, coroutines + Flow for async
128- Repository pattern wrapping Room + Retrofit
129
130**Flutter (BLoC or Riverpod):**
131- `Bloc` or `Cubit` for business logic isolation
132- `AsyncNotifierProvider` (Riverpod) for data + state
133- Repositories as abstract classes with impl injected
134
135**React Native (Redux Toolkit or Zustand):**
136- RTK Query or React Query for server state
137- Zustand slices for client state
138- Custom hooks to encapsulate business logic per feature
139
140**KMM:**
141- Shared `commonMain` holds domain + data layers
142- `expect/actual` for platform-specific implementations
143- Kotlin coroutines + Flow bridged to platform (StateFlow on Android)
144
145### Module Structure (Multi-module for large apps)
146
147```
148:app # Entry point, DI wiring
149:core:ui # Design system, shared composables
150:core:network # API client, interceptors
151:core:database # Room / SQLDelight setup
152:feature:home
153:feature:profile
154:feature:settings
155```
156
157---
158
159## §3 UI & Design
160
161### Design System First
162Before writing screens, define:
1631. **Color tokens** — Primary, secondary, surface, on-surface, error; light + dark variants
1642. **Typography scale** — Display, headline, title, body, label (Material 3 type system)
1653. **Spacing scale** — 4dp grid system (4, 8, 12, 16, 24, 32, 48dp)
1664. **Shape tokens** — Corner radii per component family
1675. **Component library** — Button, TextField, Card, BottomSheet, TopAppBar, etc.
168
169### Jetpack Compose UI Rules
170- Use `MaterialTheme` tokens; never hardcode colors/dimensions
171- `CompositionLocal` for theme, locale, haptics
172- `remember` / `rememberSaveable` correctly (saveable for UI state surviving rotation)
173- Extract large composables into sub-composables; each function ≤ 80 lines
174- Use `LazyColumn`/`LazyVerticalGrid` for lists; never `Column` with forEach for large data
175- Side effects only in `LaunchedEffect`, `DisposableEffect`, `SideEffect`
176- Avoid state hoisting anti-patterns: hoist state to the lowest common ancestor
177
178### Accessibility (Non-Negotiable)
179- All interactive elements: `contentDescription` or `semantics { }`
180- Min touch target: **48×48dp**
181- `TalkBack` compatibility tested before every release
182- Dynamic text size support (`sp` not `dp` for text)
183- Color contrast ratio ≥ 4.5:1 (WCAG AA)
184
185### Navigation
186- **Native:** Navigation Compose with typed `NavHost` and `SafeArgs` equivalent
187- **Flutter:** `go_router` with named routes and guards
188- **RN:** React Navigation v7 with typed `NavigationProp`
189- Deep link handling registered for every screen that can be externally opened
190- Back stack managed deliberately — don't push duplicates, use `popUpTo` / `launchSingleTop`
191
192### Responsive & Adaptive UI
193- Support all screen sizes: phones, foldables, tablets (`WindowSizeClass`)
194- Test at 320dp, 360dp, 411dp, 600dp+, 840dp+ widths
195- Foldable hinge awareness via `WindowInfoTracker`
196- Edge-to-edge display + `WindowInsets` handling required for Android 15+
197
198---
199
200## Best Practices
201
202### Language Standards
203
204**Kotlin:**
205- Prefer `data class`, `sealed class`, `object`, `enum class` appropriately
206- No `!!` null assertions — use `?.let`, `?: return`, `requireNotNull` with message
207- Coroutines: always specify `CoroutineScope` + `Dispatcher` explicitly; never `GlobalScope`
208- Use `@Stable` / `@Immutable` on Compose state classes for smart recomposition
209
210**Java:**
211- `@NonNull` / `@Nullable` annotations on every method param and return type
212- Never call methods on unchecked objects — null-check explicitly or use `Objects.requireNonNull`
213- Always null `binding` reference in Fragment's `onDestroyView()` to prevent memory leaks
214- Use `ExecutorService` (not `AsyncTask` — deprecated) for background work; or `LiveData` + Room's built-in threading
215- Prefer `ListAdapter` + `DiffUtil` over manual `notifyDataSetChanged()` in RecyclerView
216- Use `ViewBinding` — never `findViewById`
217
218**Dart (Flutter):**
219- Null safety required — no `!` without explicit null check above
220- Immutable state objects with `copyWith`
221- `const` constructors on all stateless widgets
222
223**TypeScript (RN):**
224- `strict: true` in tsconfig always
225- Zod or io-ts for runtime type validation of API responses
226- No `any` — use `unknown` and narrow
227
228### Dependency Management
229- Pin all dependency versions in `build.gradle.kts` / `pubspec.yaml` / `package.json`
230- Audit dependencies monthly for security vulnerabilities
231- Avoid transitive dependency conflicts — use dependency resolution strategies
232- Keep dependency count minimal — every added lib is a maintenance burden
233
234### Code Review Checklist (PR gate)
235- [ ] New public APIs have KDoc / DartDoc / JSDoc
236- [ ] No hardcoded strings — use string resources / l10n
237- [ ] No hardcoded dimensions or colors outside design tokens
238- [ ] No blocking I/O on main thread
239- [ ] No memory leaks (no `Activity` context stored in singletons)
240- [ ] Coroutine scopes / streams properly cancelled / disposed
241- [ ] Feature flag guarding any non-trivial feature
242
243---
244
245## §5 Error Handling
246
247### The Golden Rule
248**Never let exceptions propagate to the user silently or crash the app.**
249
250### Error Classification
251
252| Type | Strategy |
253|------|----------|
254| Network errors | Retry with exponential backoff; show retry UI |
255| Auth errors (401/403) | Refresh token → re-request → logout if fails |
256| Validation errors | Show inline field errors immediately |
257| Data parsing errors | Log + fallback to cached/default state |
258| Unexpected crashes | Catch at top-level; show error screen + report |
259| Background task failures | Retry via WorkManager; notify user if critical |
260
261### Result / Either Pattern (Kotlin)
262```kotlin
263sealed class AppResult<out T> {
264 data class Success<T>(val data: T) : AppResult<T>()
265 data class Error(val exception: AppException) : AppResult<Nothing>()
266}
267
268sealed class AppException(msg: String) : Exception(msg) {
269 class NetworkException(msg: String) : AppException(msg)
270 class AuthException(msg: String) : AppException(msg)
271 class ParseException(msg: String) : AppException(msg)
272 class UnknownException(msg: String) : AppException(msg)
273}
274```
275
276Use `AppResult<T>` as return type for all repository + use case functions. ViewModels map to `UiState.Error`.
277
278### Crash Reporting
279- Integrate **Firebase Crashlytics** or **Sentry** from day one
280- Set user identifiers and custom keys before crash occurs
281- Non-fatal exceptions logged for all caught errors
282- ANR monitoring enabled
283- Crash-free sessions target: **≥ 99.5%**
284
285### Offline / Network Resilience
286- Cache-first strategy: show stale data, fetch fresh in background
287- `Room` / `Drift` / `MMKV` as single source of truth
288- Expose network state via `ConnectivityManager` and reflect in UI
289- All network calls wrapped with timeout + retry policy
290
291---
292
293## §6 Testing
294
295### Testing Pyramid
296
297```
298 /\
299 /E2E\ ← 10% (UI tests: Espresso, Maestro, Appium)
300 /------\
301 / Integr \ ← 20% (Repository, DB, API contract tests)
302 /----------\
303 / Unit \ ← 70% (ViewModels, Use Cases, Utilities)
304 /--------------\
305```
306
307### Unit Tests (70%)
308- Every ViewModel, UseCase, Repository, Mapper tested
309- **Native:** JUnit5 + MockK + Turbine (Flow testing) + Kotest assertions
310- **Flutter:** `flutter_test` + `mocktail`
311- **RN:** Jest + `@testing-library/react-native` + `msw` for API mocking
312- Coverage target: **≥ 80%** on domain + presentation layers
313
314### Integration Tests (20%)
315- Room DB tests with in-memory database
316- Retrofit/Ktor tests with `MockWebServer` (OkHttp)
317- Repository tests verifying cache + remote coordination
318- API contract tests against real staging endpoint
319
320### UI / E2E Tests (10%)
321- **Espresso** for critical user journeys (login, checkout, core action)
322- **Maestro** for cross-platform E2E flows (recommended for Flutter + RN too)
323- Run on real device farm (Firebase Test Lab / BrowserStack) before release
324- Smoke test suite runs on every PR; full E2E suite nightly
325
326### Test Data Management
327- Use factories / builders for test data, never copy-paste objects
328- Hermetic tests: never share mutable state between test cases
329- Fakes over mocks for complex dependencies (repositories, data sources)
330
331---
332
333## §7 Build & Release
334
335### Build Variants
336```
337debug → dev API, logging on, no minification, debuggable
338staging → staging API, logging on, minified, not debuggable
339release → prod API, logging off, minified, signed
340```
341
342### Gradle Best Practices (Native)
343- `build.gradle.kts` only — no Groovy DSL in new projects
344- Version catalog (`libs.versions.toml`) for all dependency versions
345- `buildConfig` for environment-specific constants
346- Baseline profiles for startup performance
347- R8 full mode enabled in release; maintain proguard rules in version control
348
349### CI/CD Pipeline
350
351```
352PR Opened
353 └─ lint + unit tests + build debug APK [< 5 min]
354
355Merge to main
356 └─ unit + integration tests + staging build [< 15 min]
357 └─ deploy to Firebase App Distribution (QA)
358
359Release tag
360 └─ full test suite + E2E on device farm [< 45 min]
361 └─ build release AAB
362 └─ upload to Play Console (internal track)
363 └─ promote: internal → closed testing → open → production
364```
365
366**Recommended CI:** GitHub Actions, Bitrise, or CircleCI.
367
368### Play Store Release Strategy
369- Always release to **internal → closed → open testing** before production
370- Use **staged rollouts**: 5% → 20% → 50% → 100% with 24-48h monitoring
371- Monitor Crashlytics + ANR rate + rating before expanding rollout
372- **Never skip staged rollout** for significant changes
373
374### App Signing
375- Upload key (Play App Signing): stored in CI secrets, never committed
376- Use Google Play App Signing for distribution key management
377- Document key recovery procedure in team runbook
378
379---
380
381## §8 Performance
382
383### Startup Performance
384- App startup time target: **cold start < 1s**, warm start < 500ms
385- Use **App Startup library** for initializing libraries lazily
386- Baseline profiles generated + committed to repo
387- Heavy initialization moved off main thread
388
389### UI Performance
390- Target: **60fps** (90/120fps on supported devices); **zero jank**
391- Measure with **Android Studio Profiler** + `FrameMetrics` API
392- Avoid allocation in `draw()` / `onMeasure()` / composition
393- Use `derivedStateOf` in Compose to avoid unnecessary recompositions
394- Image loading: Coil (Compose) / Glide / Picasso — never load full-res in thumbnails
395
396### Memory
397- No `Activity` / `Context` references in ViewModels or singletons
398- WeakReferences for listeners stored beyond their owner's lifecycle
399- Bitmap recycling and memory cache sizing
400- Heap dump + leak detection via **LeakCanary** in debug builds (always)
401
402### Network
403- HTTP caching headers respected
404- Image CDN + WebP format
405- Gzip/Brotli compression verified
406- Request batching where applicable
407- Connection pooling configured
408
409### Battery
410- Background work only via **WorkManager** with appropriate constraints
411- Location updates: request only needed accuracy level; stop when backgrounded
412- Wakelocks used sparingly with explicit release
413
414---
415
416## §9 Debugging & Bug Fixing
417
418### Debugging Process
419
4201. **Reproduce reliably** — document exact steps, device, OS version, account state
4212. **Isolate** — is it UI, business logic, network, or persistence?
4223. **Instrument** — add targeted logs / breakpoints, NOT shotgun logging
4234. **Hypothesize** — form 1-3 specific hypotheses before touching code
4245. **Fix the root cause** — never patch symptoms; trace back to the source
4256. **Regression test** — write a test that fails before fix, passes after
4267. **Document** — comment explaining why the fix works, not just what it does
427
428### Common Android Bug Patterns
429
430| Bug | Likely Cause | Fix |
431|-----|-------------|-----|
432| ANR | Main thread I/O / long computation | Move to coroutine/Dispatcher.IO |
433| Memory leak | Context stored in singleton | Use `applicationContext`; WeakRef |
434| Crash on rotation | ViewModel not used; state not saved | `rememberSaveable` / ViewModel |
435| UI lag | Recomposition loops | `derivedStateOf`, stable params |
436| Blank screen after API call | Error swallowed silently | Check error state propagation |
437| Deep link not working | Manifest intent-filter missing | Verify `adb shell am start` test |
438| Push notification silent | Background restrictions | Test on real devices across OEMs |
439
440### Logging Standards
441- **Production:** Firebase Crashlytics only (no `Log.d` in release builds)
442- **Debug/Staging:** Timber with debug tree
443- Log levels: ERROR (crashes), WARN (recoverable), INFO (key events), DEBUG (dev only)
444- Never log PII — mask emails, phone numbers, tokens in logs
445
446### OEM-Specific Issues
447- Test on **Samsung**, **Xiaomi/MIUI**, **OnePlus/OxygenOS**, **Huawei (no GMS)** for critical flows
448- Background restrictions vary widely by OEM — test push, alarms, background sync
449- Maintain a physical or cloud device farm with top market-share devices
450
451---
452
453## §10 Development Roadmap
454
455Follow this phase structure for any new Android project:
456
457### Phase 0 — Foundation (Week 1-2)
458- [ ] Stack decision documented with rationale
459- [ ] Module structure defined
460- [ ] Design system tokens defined (colors, type, spacing, shapes)
461- [ ] CI pipeline running (lint + unit tests + build)
462- [ ] Crash reporting integrated (Crashlytics/Sentry)
463- [ ] Analytics baseline integrated (Firebase/Amplitude)
464- [ ] API contract / mock server set up
465- [ ] DI framework configured
466- [ ] Navigation skeleton implemented
467- [ ] Flavor/build variant config complete
468
469### Phase 1 — Core Features (Weeks 3-8)
470- [ ] Auth flow (login, register, token refresh, logout)
471- [ ] Core screen shells with real navigation
472- [ ] Network layer (client, interceptors, error handling)
473- [ ] Local persistence layer (DB schema + DAOs)
474- [ ] Repository layer wiring remote + local
475- [ ] ViewModels + UI states for each feature
476- [ ] Unit tests for all ViewModels + use cases
477- [ ] Feature flags infrastructure
478
479### Phase 2 — Polish (Weeks 9-12)
480- [ ] Design QA pass against Figma/spec
481- [ ] Accessibility audit (TalkBack, contrast, touch targets)
482- [ ] Dark mode implementation + verification
483- [ ] Localization (strings externalized, RTL support if needed)
484- [ ] Loading, empty, error states on every screen
485- [ ] Deep link handling
486- [ ] Widget / notification implementation
487- [ ] Offline mode verification
488
489### Phase 3 — Hardening (Weeks 12-14)
490- [ ] Performance profiling (startup, scroll, memory)
491- [ ] E2E test suite on device farm (Firebase Test Lab)
492- [ ] Security review (certificate pinning, biometrics, secure storage)
493- [ ] Proguard / R8 rules verified
494- [ ] Crash-free rate ≥ 99.5% on staging
495- [ ] Play Store listing, screenshots, privacy policy
496
497### Phase 4 — Release
498- [ ] AAB signed and uploaded to internal track
499- [ ] Staged rollout plan defined
500- [ ] Monitoring dashboard set up (Crashlytics, Play Console vitals)
501- [ ] Rollback plan documented
502- [ ] On-call rotation assigned
503
504### Phase 5 — Post-Launch (Ongoing)
505- Crash-free rate monitored daily
506- ANR rate < 0.47% (Play Store threshold)
507- App rating monitored; negative reviews triaged weekly
508- Dependency updates reviewed monthly
509- OS beta testing with each new Android release
510
511---
512
513## Limitations
514
515- This skill is scoped to Android and Android-adjacent delivery paths; it does not cover iOS-only architecture, App Store release operations, or Apple platform UI guidance.
516- Version numbers, Play Console policy thresholds, and recommended libraries can change; verify release-critical details against current Android, Google Play, and library documentation before shipping.
517- Code snippets are architecture patterns, not complete applications; adapt package names, dependency versions, permissions, privacy disclosures, and security controls to the actual project.
518- The guidance does not replace device QA, accessibility review, security review, legal/privacy review, or store compliance checks for a production release.
519
520## Additional Resources
521
522For stack-specific deep dives, read:
523- `references/native-android.md` — Kotlin, Compose, Room, Hilt, Coroutines
524- `references/java-android.md` — Java, XML Views, ViewBinding, LiveData, Retrofit, Room, Hilt, migration path
525- `references/flutter.md` — Dart, BLoC/Riverpod, Drift, go_router
526- `references/react-native.md` — TypeScript, RN architecture, Hermes, New Architecture
527- `references/kmm.md` — KMM shared modules, SQLDelight, Ktor, Compose Multiplatform
528- `references/hybrid.md` — Capacitor, Ionic, PWA considerations
529
530---
531
532**Source:** [`sickn33/agentic-awesome-skills`](https://github.com/sickn33/agentic-awesome-skills) → `skills/android-dev/SKILL.md`
533
534**Also appears in:** `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/android-dev/SKILL.md`, `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/android-dev/SKILL.md`