An Android app is not a program with a main function. The system starts components on your behalf, and an Activity is the one that owns a screen. A modern Compose app typically has exactly one Activity hosting every screen, because navigation happens inside Compose rather than by launching new Activities.
The manifest declares what exists: which Activity is the launcher, what permissions the app needs, and which intents it responds to. The system reads it before any of your code runs, which is why a component missing from the manifest fails at launch with a message that looks unrelated.
Gradle builds the app, and Android projects have two build files that confuse newcomers. The project-level file declares plugin versions for the whole build; the module-level file, in app/, declares that module's dependencies, its SDK levels and its build types. minSdk sets the oldest Android version you support and silently shapes which APIs you may call.
The Activity lifecycle is the part most worth internalising. onCreate runs once per creation, onStart and onResume when the screen becomes visible and interactive, and onPause/onStop on the way out. Crucially, a configuration change such as rotating the device destroys and recreates the Activity - which is exactly why state must live somewhere that survives it, as the ViewModel topic explains.
// MainActivity.kt - the single Activity hosting a Compose app
package com.example.notes
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
Text("Notes")
}
}
}
}
// app/build.gradle.kts - the module-level build file
//
// android {
// namespace = "com.example.notes"
// compileSdk = 35
// defaultConfig { minSdk = 26; targetSdk = 35 }
// buildFeatures { compose = true }
// }
//
// dependencies {
// implementation(platform("androidx.compose:compose-bom:2024.09.00"))
// implementation("androidx.compose.material3:material3")
// implementation("androidx.activity:activity-compose:1.9.2")
// }
Discussion
No questions on this topic yet. Sign in to ask the first one.