Android Gradle And AGP Workflow
Purpose
Keep Android build, dependency, variant, and packaging work grounded in the repository's real Gradle and Android Gradle Plugin configuration.
The practical decision is which Gradle files own the change, which Android modules and variants are affected, and which command proves the change without relying on machine-global state.
Source Check
Use repo-local Gradle files, checked-out dependency sources, and Dash.app Gradle or Java docsets opportunistically. Use official documentation as authority for Android-specific and version-sensitive behavior:
Translate documentation into concrete Gradle files, module names, variants, and commands.
Inspection Workflow
- Identify the Gradle owner:
settings.gradle or settings.gradle.kts
- root
build.gradle or build.gradle.kts
- module
build.gradle or build.gradle.kts
gradle/libs.versions.toml
gradle.properties
gradle/wrapper/gradle-wrapper.properties
- Identify Android plugin shape:
com.android.application
com.android.library
com.android.test
- Kotlin Android plugin aliases or IDs
- Inspect toolchain and SDK policy:
- AGP version
- Gradle wrapper version
- Kotlin plugin version
- Java toolchain or source/target compatibility
compileSdk, minSdk, and target SDK policy
- Inspect variants and packaging:
- build types
- product flavors
- signing configs
- namespace and application ID
- app bundles, APKs, ProGuard/R8, and generated outputs
- Inspect dependencies:
- version catalogs
- plugin management
- dependency constraints
- repositories
- generated sources, annotation processors, KSP, KAPT, or codegen plugins
Command Selection
Prefer repository wrappers and narrow module tasks:
./gradlew :app:assembleDebug
./gradlew :app:testDebugUnitTest
./gradlew :app:lintDebug
./gradlew :app:bundleRelease
Use the repository's documented commands when they differ. Run one Gradle command at a time.
Dependency Rules
- Use fetchable repositories or package registries only.
- Do not commit machine-local SDK, Gradle, Maven, or file dependency paths.
- Preserve version catalog and plugin-management patterns.
- Keep dependency updates separate from feature work when the update has broad risk.
- Do not raise AGP, Gradle, Kotlin, Java, compile SDK, min SDK, or target SDK without explaining compatibility impact and validation.
Failure Triage
Classify failures by phase:
- wrapper or Gradle startup
- plugin resolution
- SDK or toolchain selection
- dependency resolution
- manifest merge
- resource processing
- compile or KSP/KAPT/code generation
- unit test
- lint
- package, bundle, signing, or R8
Report the command, module, variant, phase, first meaningful error, likely cause, and smallest next check.
Output Shape
Return:
Build owner: Gradle wrapper, AGP, Kotlin plugin, Java toolchain, and Android SDK policy.
Affected modules: module names, plugins, source sets, and variants.
Dependency decision: add, update, preserve, or remove.
Packaging impact: build types, flavors, signing, bundle, APK, R8, or no packaging impact.
Validation path: exact commands.
Risk: toolchain, dependency, generated-source, variant, signing, or release risk.
Guardrails
- Do not run Gradle commands concurrently.
- Do not use machine-global Gradle when
./gradlew exists.
- Do not change SDK, AGP, Gradle, Kotlin, or Java versions as drive-by cleanup.
- Do not make server-side JVM build decisions inside Android-owned modules.
- Do not start release publishing from a build-tooling pass.
1---2name: gradle-agp-workflow3description: Inspect and maintain Android Gradle and Android Gradle Plugin workflows, including Gradle wrapper policy, AGP and Kotlin plugin versions, Java toolchains, Android SDK settings, namespaces, variants, flavors, signing config, version catalogs, dependencies, generated sources, build cache boundaries, and targeted assemble, test, lint, or bundle tasks.4license: Apache-2.05---67# Android Gradle And AGP Workflow89## Purpose1011Keep Android build, dependency, variant, and packaging work grounded in the repository's real Gradle and Android Gradle Plugin configuration.1213The practical decision is which Gradle files own the change, which Android modules and variants are affected, and which command proves the change without relying on machine-global state.1415## Source Check1617Use repo-local Gradle files, checked-out dependency sources, and Dash.app Gradle or Java docsets opportunistically. Use official documentation as authority for Android-specific and version-sensitive behavior:1819- [Android build documentation](https://developer.android.com/build)20- [Android Gradle Plugin release notes](https://developer.android.com/build/releases/gradle-plugin)21- [Gradle User Manual](https://docs.gradle.org/current/userguide/userguide.html)22- [Gradle Java Toolchains](https://docs.gradle.org/current/userguide/toolchains.html)23- [Kotlin Gradle plugin documentation](https://kotlinlang.org/docs/gradle.html)2425Translate documentation into concrete Gradle files, module names, variants, and commands.2627## Inspection Workflow28291. Identify the Gradle owner:30 - `settings.gradle` or `settings.gradle.kts`31 - root `build.gradle` or `build.gradle.kts`32 - module `build.gradle` or `build.gradle.kts`33 - `gradle/libs.versions.toml`34 - `gradle.properties`35 - `gradle/wrapper/gradle-wrapper.properties`362. Identify Android plugin shape:37 - `com.android.application`38 - `com.android.library`39 - `com.android.test`40 - Kotlin Android plugin aliases or IDs413. Inspect toolchain and SDK policy:42 - AGP version43 - Gradle wrapper version44 - Kotlin plugin version45 - Java toolchain or source/target compatibility46 - `compileSdk`, `minSdk`, and target SDK policy474. Inspect variants and packaging:48 - build types49 - product flavors50 - signing configs51 - namespace and application ID52 - app bundles, APKs, ProGuard/R8, and generated outputs535. Inspect dependencies:54 - version catalogs55 - plugin management56 - dependency constraints57 - repositories58 - generated sources, annotation processors, KSP, KAPT, or codegen plugins5960## Command Selection6162Prefer repository wrappers and narrow module tasks:6364```bash65./gradlew :app:assembleDebug66./gradlew :app:testDebugUnitTest67./gradlew :app:lintDebug68./gradlew :app:bundleRelease69```7071Use the repository's documented commands when they differ. Run one Gradle command at a time.7273## Dependency Rules7475- Use fetchable repositories or package registries only.76- Do not commit machine-local SDK, Gradle, Maven, or file dependency paths.77- Preserve version catalog and plugin-management patterns.78- Keep dependency updates separate from feature work when the update has broad risk.79- Do not raise AGP, Gradle, Kotlin, Java, compile SDK, min SDK, or target SDK without explaining compatibility impact and validation.8081## Failure Triage8283Classify failures by phase:8485- wrapper or Gradle startup86- plugin resolution87- SDK or toolchain selection88- dependency resolution89- manifest merge90- resource processing91- compile or KSP/KAPT/code generation92- unit test93- lint94- package, bundle, signing, or R89596Report the command, module, variant, phase, first meaningful error, likely cause, and smallest next check.9798## Output Shape99100Return:1011021. `Build owner`: Gradle wrapper, AGP, Kotlin plugin, Java toolchain, and Android SDK policy.1032. `Affected modules`: module names, plugins, source sets, and variants.1043. `Dependency decision`: add, update, preserve, or remove.1054. `Packaging impact`: build types, flavors, signing, bundle, APK, R8, or no packaging impact.1065. `Validation path`: exact commands.1076. `Risk`: toolchain, dependency, generated-source, variant, signing, or release risk.108109## Guardrails110111- Do not run Gradle commands concurrently.112- Do not use machine-global Gradle when `./gradlew` exists.113- Do not change SDK, AGP, Gradle, Kotlin, or Java versions as drive-by cleanup.114- Do not make server-side JVM build decisions inside Android-owned modules.115- Do not start release publishing from a build-tooling pass.