1---2name: android-gradle-build-performance3description: Diagnose and improve Android and Gradle build performance with scans, cache checks, and bottleneck audits.4---5# Android Gradle Build Performance67## When To Use8- Use this skill when the request is about: android gradle build performance, configuration cache android build, ksp vs kapt android.9- Primary outcome: Diagnose and improve Android and Gradle build performance with scans, cache checks, and bottleneck audits.10- Use this skill when the problem is build speed, task churn, cache misses, or CI wall time rather than build-logic structure.11- Read `references/patterns.md` when you need the measurement ladder or the most common Gradle performance smells.12- Read `references/scenarios.md` for audit-first entry points on the example projects.13- Handoff skills when the scope expands:14- `android-gradle-build-logic`15- `android-ci-cd-release-playstore`1617## Workflow181. Identify whether the problem is local developer feedback time, CI build duration, or both.192. Measure one build path at a time with `--profile`, `--scan`, configuration-cache diagnostics, or the bundled audit script before proposing a fix.203. Check `gradle.properties`, plugin wiring, dependency declarations, task registration style, and module conventions for common performance smells.214. Apply one high-confidence optimization at a time, then compare before and after behavior instead of stacking changes.225. Hand off structural Gradle refactors or release-pipeline changes once the performance bottleneck is isolated.2324## Guardrails25- Do not recommend broad rewrites when a single cache, plugin, or dependency pattern is the real bottleneck.26- Separate measurement from speculation; call out what was observed vs inferred.27- Prefer KSP, configuration cache, and lazy task configuration when the toolchain supports them.28- Treat dynamic dependency versions, changing modules, and eager task creation as performance regressions unless there is a deliberate reason.29- Keep CI guidance reproducible on the example projects before suggesting org-wide rollout.3031## Anti-Patterns32- Turning on every Gradle flag without checking compatibility or failures.33- Blaming AGP upgrades for slow builds without measuring task hot spots.34- Mixing build-logic architecture advice with build-time diagnosis in one pass.35- Using dynamic dependency versions that force repeated resolution work.3637## Review Focus38- Configuration time vs execution time vs dependency resolution vs test wall time.39- Configuration cache compatibility and lazy task registration.40- KSP vs kapt and annotation-processor hotspots.41- Remote/local cache value, dynamic dependencies, and CI-specific bottlenecks.4243## Examples44### Happy path45- Scenario: Audit the Compose fixture for build cache, configuration cache, KSP, and eager task creation smells.46- Command: `python3 skills/android-gradle-build-performance/scripts/audit_build_performance.py examples/orbittasks-compose --json`4748### Edge case49- Scenario: Compare XML and Compose fixture build settings before choosing a CI build optimization.50- Command: `bash skills/android-gradle-build-performance/scripts/run_examples.sh`5152### Failure recovery53- Scenario: Re-check a project after enabling performance flags so regressions are caught before rollout.54- Command: `python3 skills/android-gradle-build-performance/scripts/audit_build_performance.py examples/orbittasks-xml`5556## Done Checklist57- The bottleneck is tied to a specific phase, flag, plugin, or dependency pattern.58- Proposed optimizations are measurable and reversible.59- The recommended fix is compatible with the current Android and Gradle toolchain.60- Structural Gradle work is handed off separately from performance tuning.6162## Official References63- [https://docs.gradle.org/current/userguide/performance.html](https://docs.gradle.org/current/userguide/performance.html)64- [https://docs.gradle.org/current/userguide/configuration_cache.html](https://docs.gradle.org/current/userguide/configuration_cache.html)65- [https://docs.gradle.org/current/userguide/task_configuration_avoidance.html](https://docs.gradle.org/current/userguide/task_configuration_avoidance.html)66- [https://developer.android.com/build/optimize-your-build](https://developer.android.com/build/optimize-your-build)67- [https://developer.android.com/build/ksp](https://developer.android.com/build/ksp)