Android Gradle Logic
Expert guidance on setting up scalable Gradle build logic using Convention Plugins and...
Install
npx skills add new-silvermoon/awesome-android-agent-skills --skill android-gradle-logic -g -a claude-code -y- Repository
- new-silvermoon/awesome-android-agent-skills998
- Category
- Engineering
- Updated
- 3mo ago
- License
- Apache-2.0
- Context cost
- Lightabout 799 tokens
- Runs scripts
- No, instructions only
What it does
Expert guidance on setting up scalable Gradle build logic using Convention Plugins and Version Catalogs.
Android Gradle Build Logic & Convention Plugins
This skill helps you configure a scalable, maintainable build system for Android apps using Gradle Convention Plugins and Version Catalogs, following the "Now in Android" (NiA) architecture.
Goal
Stop copy-pasting code between build.gradle.kts files. Centralize build logic (Compose setup, Kotlin options, Hilt, etc.) in reusable plugins.
Project Structure
Ensure your project has a build-logic directory included in settings.gradle.kts as a composite build.
root/
├── build-logic/
│ ├── convention/
│ │ ├── src/main/kotlin/
│ │ │ └── AndroidApplicationConventionPlugin.kt
│ │ └── build.gradle.kts
│ ├── build.gradle.kts
│ └── settings.gradle.kts
├── gradle/
│ └── libs.versions.toml
├── app/
│ └── build.gradle.kts
└── settings.gradle.kts
Step 1: Configure settings.gradle.kts
Include the build-logic as a plugin management source.
// settings.gradle.kts
pluginManagement {
includeBuild("build-logic")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
Step 2: Define Dependencies in libs.versions.toml
Use the Version Catalog for both libraries and plugins.
[versions]
androidGradlePlugin = "8.2.0"
kotlin = "1.9.20"
[libraries]
# ...
[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
# Define your own plugins here
nowinandroid-android-application = { id = "nowinandroid.android.application", version = "unspecified" }
