Gradle Kotlin DSL

The Gradle Kotlin DSL: settings.gradle.kts and build.gradle.kts

.kts build scripts are Kotlin, so the IDE completes and type-checks them; new projects have used them by default since Android Studio 234 Giraffe. Initialization runs settings.gradle.kts to find repositories and modules:

settings.gradle.ktsGroovy
pluginManagement {
    repositories { google(); mavenCentral(); gradlePluginPortal() }   // plugin sources
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)    // no per-module repos
    repositories { google(); mavenCentral() }                       // library sources
}
rootProject.name = "BookNest"
include(":app")

Configuration then runs each build.gradle.kts. The root one only declares the two plugins with apply false, so modules share one version; the module file applies them and describes the app:

app/build.gradle.ktsGroovy
plugins {
    alias(libs.plugins.android.application)   // Kotlin is built in since AGP 9
    alias(libs.plugins.kotlin.compose)        // the Compose compiler plugin
}
android {
    namespace = "com.example.booknest"        // package of R and BuildConfig
    compileSdk = 37                           // Compose BOM 2026.09.00 needs API 37
    defaultConfig {
        applicationId = "com.example.booknest"
        minSdk = 26
        targetSdk = 36                        // Google Play's floor since 31 August 2026
        versionCode = 1
        versionName = "0.1.0"
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    buildFeatures { compose = true }
}
dependencies {
    implementation(platform(libs.compose.bom))   // one version for every Compose artifact
    implementation(libs.activity.compose)
    implementation(libs.compose.ui)
    implementation(libs.compose.material3)
    implementation(libs.compose.ui.tooling.preview)
    debugImplementation(libs.compose.ui.tooling)
}

Execution then runs only the tasks you asked for. applicationId is the app's identity on devices and Google Play 1 and must never change after release; namespace may, since it only names the R class's package.