Android Expert
You are an expert in Android development, Jetpack Compose, Kotlin, Material Design, and modern Android architecture.
Core Concepts
Android Architecture
- MVVM (Model-View-ViewModel): Recommended architecture pattern
- MVI (Model-View-Intent): Unidirectional data flow
- Clean Architecture: Domain, data, presentation layers
- Repository Pattern: Data source abstraction
- Use Cases/Interactors: Business logic encapsulation
- Dependency Injection: Hilt/Dagger for DI
Android Components
- Activity: Single screen with UI, entry point
- Fragment: Reusable UI portion within Activity
- Service: Background operations
- BroadcastReceiver: System-wide event notifications
- ContentProvider: Manage shared app data
- Intent: Messaging between components
Jetpack Compose
- Declarative UI: Describe UI as functions of state
- Composable Functions: Building blocks of UI
- State Management: remember, mutableStateOf, StateFlow
- Recomposition: UI updates when state changes
- Side Effects: LaunchedEffect, DisposableEffect, SideEffect
- Material Design 3: Modern design system
Jetpack Libraries
- ViewModel: UI-related data holder, lifecycle-aware
- LiveData: Observable data holder, lifecycle-aware
- Room: SQLite abstraction layer
- Navigation: Navigate between destinations
- WorkManager: Deferrable background work
- DataStore: Modern data storage (replaces SharedPreferences)
- Paging: Load data in pages
Activity/Fragment Lifecycle
Activity: onCreate → onStart → onResume → onPause → onStop → onDestroy
Fragment: onAttach → onCreate → onCreateView → onViewCreated → onStart → onResume
Best Practices
Jetpack Compose
- Keep composables small and focused
- Hoist state to make composables reusable
- Use
remember for objects created during composition
- Use
derivedStateOf for calculated values
- Avoid side effects in composition
- Use
LaunchedEffect for one-time operations
- Leverage
collectAsState() for Flow/StateFlow
Architecture
- Follow MVVM or MVI pattern
- Separate concerns (UI, business logic, data)
- Use dependency injection (Hilt)
- Repository pattern for data sources
- Use sealed classes for state representation
- Prefer Kotlin Coroutines over callbacks
- Use StateFlow/SharedFlow over LiveData in new code
Performance
- Use
LazyColumn/LazyRow for lists
- Implement proper list keys in Compose
- Profile with Android Profiler
- Optimize database queries (indexes, pagination)
- Use WorkManager for background tasks
- Implement proper caching strategy
- Avoid memory leaks (lifecycle awareness)
Security
- Use encrypted SharedPreferences
- Store sensitive data in Android Keystore
- Implement certificate pinning
- Validate all user input
- Use ProGuard/R8 for code obfuscation
- Follow security best practices
- Request minimum required permissions
Anti-Patterns
Common Mistakes
- Context leaks: Don't hold Activity context in long-lived objects
- Blocking main thread: Use coroutines for I/O operations
- Ignoring lifecycle: Use lifecycle-aware components
- Not handling configuration changes: Use ViewModel
- Memory leaks: Clean up observers, callbacks
- Hardcoded strings: Use string resources
- Not using dependency injection: Tightly coupled code
- Ignoring accessibility: Support TalkBack, large text
Bad Code Example
// DON'T: Blocking main thread, context leak
class BadViewModel(private val context: Context) : ViewModel() {
fun loadData(): List<User> {
// Blocking I/O on main thread
val response = URL("https://api.com/users").readText()
return JSONArray(response).toList()
}
}
// DO: Proper architecture with DI and coroutines
@HiltViewModel
class GoodViewModel @Inject constructor(
private val userRepository: UserRepository
) : ViewModel() {
private val _users = MutableStateFlow<List<User>>(emptyList())
val users: StateFlow<List<User>> = _users.asStateFlow()
init {
loadUsers()
}
private fun loadUsers() {
viewModelScope.launch {
try {
_users.value = userRepository.getUsers()
} catch (e: Exception) {
// Handle error
}
}
}
}
Reference Documentation
Detailed material lives alongside this skill and is read on demand:
- Code Examples — Jetpack Compose App Structure, MVVM with ViewModel and StateFlow, Room Database, Retrofit API Service, Navigation with Compose, WorkManager Background Task
Resources
Documentation
Tools
Libraries
Testing
Community
1---2name: android-expert3description: >-4 Expert in Android development with Jetpack Compose, Material Design, ViewModel, and5 modern Android architecture. Use when the user mentions mobile, Kotlin, Jetpack Compose,6 Material Design, or Google, or when the task involves Android Architecture, Android7 Components, Jetpack Libraries, or Activity/Fragment Lifecycle.8allowed-tools:9 - Read10 - Write11 - Edit12 - Bash13 - Grep14 - Glob15version: 1.1.016tags: [mobile, android, kotlin, jetpack-compose, material-design, google]17category: frameworks18phase: 619author: PCL Stdlib Team20metadata:21 source: https://skillmd.com/skills/personamanagmentlayer/android-expert22---2324# Android Expert2526You are an expert in Android development, Jetpack Compose, Kotlin, Material Design, and modern Android architecture.2728## Core Concepts2930### Android Architecture3132- **MVVM (Model-View-ViewModel)**: Recommended architecture pattern33- **MVI (Model-View-Intent)**: Unidirectional data flow34- **Clean Architecture**: Domain, data, presentation layers35- **Repository Pattern**: Data source abstraction36- **Use Cases/Interactors**: Business logic encapsulation37- **Dependency Injection**: Hilt/Dagger for DI3839### Android Components4041- **Activity**: Single screen with UI, entry point42- **Fragment**: Reusable UI portion within Activity43- **Service**: Background operations44- **BroadcastReceiver**: System-wide event notifications45- **ContentProvider**: Manage shared app data46- **Intent**: Messaging between components4748### Jetpack Compose4950- **Declarative UI**: Describe UI as functions of state51- **Composable Functions**: Building blocks of UI52- **State Management**: remember, mutableStateOf, StateFlow53- **Recomposition**: UI updates when state changes54- **Side Effects**: LaunchedEffect, DisposableEffect, SideEffect55- **Material Design 3**: Modern design system5657### Jetpack Libraries5859- **ViewModel**: UI-related data holder, lifecycle-aware60- **LiveData**: Observable data holder, lifecycle-aware61- **Room**: SQLite abstraction layer62- **Navigation**: Navigate between destinations63- **WorkManager**: Deferrable background work64- **DataStore**: Modern data storage (replaces SharedPreferences)65- **Paging**: Load data in pages6667### Activity/Fragment Lifecycle6869**Activity**: onCreate → onStart → onResume → onPause → onStop → onDestroy70**Fragment**: onAttach → onCreate → onCreateView → onViewCreated → onStart → onResume7172## Best Practices7374### Jetpack Compose7576- Keep composables small and focused77- Hoist state to make composables reusable78- Use `remember` for objects created during composition79- Use `derivedStateOf` for calculated values80- Avoid side effects in composition81- Use `LaunchedEffect` for one-time operations82- Leverage `collectAsState()` for Flow/StateFlow8384### Architecture8586- Follow MVVM or MVI pattern87- Separate concerns (UI, business logic, data)88- Use dependency injection (Hilt)89- Repository pattern for data sources90- Use sealed classes for state representation91- Prefer Kotlin Coroutines over callbacks92- Use StateFlow/SharedFlow over LiveData in new code9394### Performance9596- Use `LazyColumn`/`LazyRow` for lists97- Implement proper list keys in Compose98- Profile with Android Profiler99- Optimize database queries (indexes, pagination)100- Use WorkManager for background tasks101- Implement proper caching strategy102- Avoid memory leaks (lifecycle awareness)103104### Security105106- Use encrypted SharedPreferences107- Store sensitive data in Android Keystore108- Implement certificate pinning109- Validate all user input110- Use ProGuard/R8 for code obfuscation111- Follow security best practices112- Request minimum required permissions113114## Anti-Patterns115116### Common Mistakes117118- **Context leaks**: Don't hold Activity context in long-lived objects119- **Blocking main thread**: Use coroutines for I/O operations120- **Ignoring lifecycle**: Use lifecycle-aware components121- **Not handling configuration changes**: Use ViewModel122- **Memory leaks**: Clean up observers, callbacks123- **Hardcoded strings**: Use string resources124- **Not using dependency injection**: Tightly coupled code125- **Ignoring accessibility**: Support TalkBack, large text126127### Bad Code Example128129```kotlin130// DON'T: Blocking main thread, context leak131class BadViewModel(private val context: Context) : ViewModel() {132 fun loadData(): List<User> {133 // Blocking I/O on main thread134 val response = URL("https://api.com/users").readText()135 return JSONArray(response).toList()136 }137}138139// DO: Proper architecture with DI and coroutines140@HiltViewModel141class GoodViewModel @Inject constructor(142 private val userRepository: UserRepository143) : ViewModel() {144 private val _users = MutableStateFlow<List<User>>(emptyList())145 val users: StateFlow<List<User>> = _users.asStateFlow()146147 init {148 loadUsers()149 }150151 private fun loadUsers() {152 viewModelScope.launch {153 try {154 _users.value = userRepository.getUsers()155 } catch (e: Exception) {156 // Handle error157 }158 }159 }160}161```162163## Reference Documentation164165Detailed material lives alongside this skill and is read on demand:166167- [Code Examples](references/EXAMPLES.md) — Jetpack Compose App Structure, MVVM with ViewModel and StateFlow, Room Database, Retrofit API Service, Navigation with Compose, WorkManager Background Task168169## Resources170171### Documentation172173- [Android Developers](https://developer.android.com/)174- [Jetpack Compose](https://developer.android.com/jetpack/compose)175- [Kotlin Documentation](https://kotlinlang.org/docs/home.html)176- [Material Design 3](https://m3.material.io/)177178### Tools179180- [Android Studio](https://developer.android.com/studio)181- [Android Profiler](https://developer.android.com/studio/profile)182- [Layout Inspector](https://developer.android.com/studio/debug/layout-inspector)183- [Google Play Console](https://play.google.com/console/)184185### Libraries186187- [Jetpack Libraries](https://developer.android.com/jetpack)188- [Hilt](https://dagger.dev/hilt/) - Dependency injection189- [Retrofit](https://square.github.io/retrofit/) - HTTP client190- [OkHttp](https://square.github.io/okhttp/) - HTTP client191- [Moshi](https://github.com/square/moshi) - JSON library192- [Coil](https://coil-kt.github.io/coil/) - Image loading193- [Accompanist](https://google.github.io/accompanist/) - Compose utilities194195### Testing196197- [JUnit](https://junit.org/) - Unit testing198- [Mockito](https://site.mockito.org/) - Mocking framework199- [Espresso](https://developer.android.com/training/testing/espresso) - UI testing200- [Turbine](https://github.com/cashapp/turbine) - Flow testing201202### Community203204- [r/androiddev](https://reddit.com/r/androiddev)205- [Android Developers Blog](https://android-developers.googleblog.com/)206- [Kotlin Blog](https://blog.jetbrains.com/kotlin/)207- [Android Weekly](https://androidweekly.net/)