Android Kotlin Patterns
Production Android development with Kotlin and Jetpack.
Architecture (Modern Android Dev)
Recommended Stack
- UI: Jetpack Compose with Material 3
- State: ViewModel + StateFlow
- DI: Hilt/Dagger
- DB: Room
- Network: Retrofit + OkHttp
- Async: Coroutines + Flow
- Navigation: Compose Navigation
Project Structure
app/
├── data/
│ ├── local/ (Room DAOs, entities)
│ ├── remote/ (Retrofit APIs, DTOs)
│ └── repository/
├── domain/
│ ├── model/
│ └── usecase/
├── ui/
│ ├── components/
│ ├── screens/
│ └── theme/
└── di/ (Hilt modules)
Jetpack Compose Patterns
State Hoisting
// State flows down, events flow up
@Composable
fun CounterScreen(viewModel: CounterViewModel = hiltViewModel()) {
val state by viewModel.state.collectAsStateWithLifecycle()
CounterContent(
count = state.count,
)
}
Performance
- Use
rememberandderivedStateOffor computations LazyColumnfor lists, notColumnwith scrolling- Stable types via
@Immutable/@Stableannotations
Play Store Submission
- Privacy Policy URL set
- App signing key backed up
- In-app reviews integrated
- Crash reporting (Firebase)
- proguard-rules.pro configured
- App bundles (.aab) for distribution