Composables

Android Gradle Logic

Community

rcosteira79

Use when setting up or refactoring Android Gradle build logic — convention plugins, composite builds, version catalogs, and shared build configuration across modules.

Overview

Repository
rcosteira79/android-skills
Publisher
rcosteira79
Stars
174
Forks
21
Bundled files
0
License
MIT
Updated
Nov 10, 2026

Installation

tmp=$(mktemp -d)
git clone --depth 1 https://github.com/rcosteira79/android-skills.git "$tmp"
mkdir -p ~/.claude/skills
cp -R "$tmp/plugins/android-skills/skills/android-gradle-logic" ~/.claude/skills/android-gradle-logic
rm -rf "$tmp"

Instructions

Android Gradle Build Logic

Centralise build configuration in reusable Convention Plugins inside a build-logic/ composite build, so each module's build.gradle.kts collapses to plugins { alias(libs.plugins.myapp.android.library) } plus a namespace.

The canonical worked example is nowinandroid's build-logic/ — start from it rather than hand-rolling. This skill covers the wiring detail that is easy to get wrong, plus the AGP 9 deltas.

The wiring gotcha

build-logic does NOT inherit the root version catalog — recreate it. A composite build has its own settings.gradle.kts; the root libs catalog is invisible inside build-logic until you declare it. Without this the convention plugins can't reference libs.* and fail to compile with Unresolved reference: libs:

// build-logic/settings.gradle.kts
dependencyResolutionManagement {
    versionCatalogs {
        create("libs") { from(files("../gradle/libs.versions.toml")) }
    }
}

Applying the plugins from the catalog

Declare the convention-plugin ids in [plugins] so modules can apply them by alias. The id must match the one you register(...) in build-logic — a mismatch is the usual cause of an alias that won't resolve:

# gradle/libs.versions.toml
[plugins]
myapp-android-application = { id = "myapp.android.application" }
myapp-android-library     = { id = "myapp.android.library" }
myapp-android-compose     = { id = "myapp.android.compose" }

A version is not required for a locally-registered plugin — the included build supplies it, so the alias resolves whatever the catalog does or doesn't declare. nowinandroid writes version = "unspecified" explicitly, which is fine and self-documenting, just not load-bearing.

Set shared configuration — compileSdk / minSdk / Compose / the JVM toolchain — once inside the convention plugins rather than per module. For a Kotlin Android module kotlin { jvmToolchain(21) } is the idiomatic one-liner, and it sets the toolchain for both Kotlin and Java compilation:

kotlin { jvmToolchain(21) }

AGP 9 Implications

The convention plugin pattern above targets AGP 8. AGP 9 changes several things that hit build logic directly: it drops the standalone org.jetbrains.kotlin.android plugin (Kotlin is built into com.android.application / com.android.library), removes BaseExtension and the old variant APIs (applicationVariants → androidComponents { onVariants { … } }), moves kotlinOptions {} to a top-level kotlin { compilerOptions { … } }, and makes kapt incompatible (migrate to KSP). Any convention plugin that touches these needs updating.

Defer to the dedicated migration skills for the mechanics rather than duplicating the steps here: Google's agp-9-upgrade for pure-Android projects, JetBrains' kotlin-tooling-agp9-migration for KMP, and this repo's gradle-build-performance skill for the kapt → KSP step.

Checklist

  • build-logic included as a composite build (includeBuild("build-logic")) in the root settings.gradle.kts
  • build-logic/settings.gradle.kts recreates the libs catalog via from(files("../gradle/libs.versions.toml"))
  • Convention plugins register-ed with stable ids, and the [plugins] alias ids match them exactly
  • compileSdk / minSdk / Compose / JVM toolchain set once in the plugins, not per module

FAQ

What does Android Gradle Logic do?

Use when setting up or refactoring Android Gradle build logic — convention plugins, composite builds, version catalogs, and shared build configuration across modules.

Who made Android Gradle Logic?

rcosteira79 (a community member) publishes it in the rcosteira79/android-skills repository on GitHub.

Is Android Gradle Logic free?

Yes. Android Gradle Logic is open source, published by rcosteira79 under the MIT license.

What comes with Android Gradle Logic?

Just its instructions. Everything the agent needs is in one SKILL.md file.

Which agents can use Android Gradle Logic?

Any coding agent that reads SKILL.md files, including Claude Code, Codex, Cursor, GitHub Copilot and Gemini CLI. The agent loads the skill when a task matches its description.

What are agent skills?

An agent skill is a folder with a SKILL.md file: instructions that teach a coding agent how to do one kind of task, and optionally files it can read while it works. The agent keeps only the skill's name and description in mind and reads the rest when a task calls for it.

How are agent skills different from MCP servers?

An MCP server gives an agent new tools to call, code that runs somewhere and returns results. A skill gives it knowledge: how to approach a task with the tools it already has. Many agents use both.

How can my agent test my Android app?

Robomori lets coding agents create, start and control Android emulators and devices from one command, so they can install your app, take screenshots and check dark mode, font sizes and languages.

You're subscribed

The next lesson lands in on Wednesday.