gradle-best-practices
Skill1 starsChanged 9 days agoMITView on GitHub
Gradle Kotlin DSL and version catalog best practices for Android projects in 2025-2026 — covers TOML version catalog, Kotlin 2.0+ Compose setup, SDK targets, ProGuard, and AGP compatibility. Loaded when editing Gradle files.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- camunda/camundatheir own version, first seen Oct 17, 2026
- gradle/gradle-skillstheir own version, first seen Sep 30, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- camunda/camunda★ 4.4ksame name
- gradle/gradle-skills★ 72same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- keystore-conventionsSkill
- multi-app-structureSkill
- package-namingSkill
- release-workflowSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
All dependency versions belong in gradle/libs.versions.toml — never hardcode versions in build.gradle.kts
- Very specific: line 17
Use implementation(libs.xxx) — never Groovy syntax like implementation 'xxx:yyy:1.0'
- Very specific: line 100
Check gradle/wrapper/gradle-wrapper.properties when updating AGP.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Gradle Best Practices for Android (2025–2026)
Always use version catalog
- All dependency versions belong in
gradle/libs.versions.toml— never hardcode versions inbuild.gradle.kts - Reference with type-safe accessors:
implementation(libs.androidx.core.ktx)notimplementation("androidx.core:core-ktx:1.13.1") - BOM imports:
implementation(platform(libs.androidx.compose.bom))
Kotlin DSL (.kts) rules
- Use
implementation(libs.xxx)— never Groovy syntax likeimplementation 'xxx:yyy:1.0' - Type-safe accessors are preferred over string-based references
buildFeatures { compose = true }required for Compose projects
Kotlin 2.0+ Compose setup (current standard)
// In plugins block of app/build.gradle.kts:
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose) // ← required for Kotlin 2.0+
}# In libs.versions.toml plugins block:
[plugins]
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }Do NOT use kotlinOptions { kotlinCompilerExtensionVersion = "..." } — this is deprecated for Kotlin 2.0+.
SDK target versions
android {
compileSdk = 36 // Android 16
defaultConfig {
minSdk = 24 // Android 7.0 — ~96% device coverage
targetSdk = 36
}
}Play Store requirement: targetSdk must meet Google's current minimum target API level (check Play Console's target API requirements). Apps with outdated targetSdk receive policy warnings.
Java / Kotlin compile options
kotlinOptions is deprecated; set the JVM target with compilerOptions in a top-level kotlin {} block (outside android {}).
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}ProGuard for release builds (required)
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}Both isMinifyEnabled and isShrinkResources must be true for release. This reduces APK/AAB size significantly.
AGP ↔ Gradle wrapper compatibility
| AGP version | Min Gradle version |
| 8.5.x | 8.7+ |
| 8.4.x | 8.6+ |
| 8.3.x | 8.4+ |
| 8.2.x | 8.2+ |
Check gradle/wrapper/gradle-wrapper.properties when updating AGP.
Signing config via local.properties (recommended)
import java.util.Properties
val localProps = Properties().apply {
file("../local.properties").takeIf { it.exists() }?.inputStream()?.use { load(it) }
}
android {
signingConfigs {
create("release") {
storeFile = file(localProps["KEYSTORE_PATH"] as String)
storePassword = localProps["KEYSTORE_PASSWORD"] as String
keyAlias = localProps["KEY_ALIAS"] as String
keyPassword = localProps["KEY_PASSWORD"] as String
}
}
}local.properties is excluded from git by Android Studio's default .gitignore — never commit it.
Build commands reference
./gradlew clean # Clean all build outputs
./gradlew bundleRelease # Build release AAB (for Play Store)
./gradlew assembleRelease # Build release APK (for direct install)
./gradlew signingReport # Verify signing configuration
./gradlew dependencies # Show full dependency treeDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

