Gradle — How the App Gets Built
You press Run and, a few seconds later, Sprout appears on the emulator. Between those two moments, a tool compiled your code, packed your images, downloaded libraries and signed the result. That tool is Gradle, and you steer it with a few short files.
The rule
Settings names the modules; each module's build file says how to build it.
An Android project has a small set of Gradle files:
settings.gradle.kts— lists the modules in the project, likeinclude(":app"), and where to download libraries from.build.gradle.ktsin the project root — shared plugin setup.app/build.gradle.kts— the important one: how to build the app module.gradle/libs.versions.toml— the version catalog, one place for library versions.
android {
namespace = "com.example.sprout"
compileSdk = 35
defaultConfig {
applicationId = "com.example.sprout"
minSdk = 26 // oldest Android version allowed
targetSdk = 35 // version the app is designed for
versionCode = 3 // internal number, must go up each release
versionName = "1.2" // what users see
}
}
dependencies {
implementation(libs.androidx.activity.compose)
}applicationId is the app's unique identity on a device and in the store. implementation(...) adds a library your code can use.
The shortcut
For any build question, ask "which file owns this?" Project-wide list → settings. Anything about one app → its module file.
Pick the owner
Only the app module uses it →
app/build.gradle.kts.
You can also build from a terminal with the Gradle wrapper, which downloads the right Gradle version for you:
./gradlew assembleDebugA classic mistake is editing a build file and forgetting to sync: the code then cannot "see" the new library.
Drills
Answer fast — trust the rule.
Which file lists the modules that make up the project?
Sprout sets minSdk = 26. What does that control?
Which value must increase every time you publish a new release?
What does ./gradlew assembleDebug do?
Remember
- Settings names the modules; each module's build file says how to build it.
- Ask "which file owns this?" before editing.
- After changing a build file, sync.
