Android Components, Lifecycle & Gradle
Activities, the lifecycle, configuration changes, intents, the manifest, resources and the Gradle build system.
Intermediate · about 8 hours · difficulty 3/5
Learn first: Native Android (Kotlin + Jetpack Compose), Kotlin Essentials
Even in a Compose-only app, the Android system talks to you through components and lifecycle callbacks. Misunderstanding them causes the most classic Android bugs.
Components
- Activity: an entry point with a window; modern apps often use a single activity hosting Compose.
- Service, BroadcastReceiver and ContentProvider: background work, system events and shared data (you will use these less directly now, through Jetpack libraries).
- Intents start components and talk to other apps (share sheets, opening a URL).
Lifecycle
Activities move through onCreate, onStart, onResume, onPause, onStop, onDestroy. Configuration changes such as rotation or dark mode toggling recreate the activity by default, so state must live in a ViewModel or be saved with rememberSaveable. The system may also kill your process in the background (process death); test it with "Don't keep activities" in developer options.
Build system
Gradle with Kotlin DSL (build.gradle.kts), version catalogs (libs.versions.toml), build types (debug/release) and product flavors (free/paid, staging/prod). minSdk, targetSdk and compileSdk control compatibility.
Good enough to move on: your app keeps its state across rotation and process death, and has debug and release build types configured.
Key concepts
- Activities and single-activity apps
- Activity lifecycle
- Configuration changes and process death
- Intents
- Manifest and resources
- Gradle Kotlin DSL and version catalogs
- Build types and product flavors
- Services and broadcast receivers
Mini project
Build a counter app that survives rotation, dark mode toggling and process death, with a share button that uses an intent.
Check yourself
What is process death, and how do you test that your app recovers from it?
Free resources
- The activity lifecycle (Android Developers)
- Configure your build (Android Developers)
- Android courses (Android Developers)