
gradle-build-performance
Debug and optimize Android/Gradle build performance. Use when builds are slow, investigating CI/CD performance, analyzing build scans, or identifying compilation bottlenecks.
- Installs
- 783
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill gradle-build-performance- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads gradle-build-performance automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Gradle Build Performance
When to Use
- Build times are slow (clean or incremental)
- Investigating build performance regressions
- Analyzing Gradle Build Scans
- Identifying configuration vs execution bottlenecks
- Optimizing CI/CD build times
- Enabling Gradle Configuration Cache
- Reducing unnecessary recompilation
- Debugging kapt/KSP annotation processing
Example Prompts
- "My builds are slow, how can I speed them up?"
- "How do I analyze a Gradle build scan?"
- "Why is configuration taking so long?"
- "Why does my project always recompile everything?"
- "How do I enable configuration cache?"
- "Why is kapt so slow?"
Workflow
- Measure Baseline — Clean build + incremental build times
- Generate Build Scan —
./gradlew assembleDebug --scan - Identify Phase — Configuration? Execution? Dependency resolution?
- Apply ONE optimization — Don't batch changes
- Measure Improvement — Compare against baseline
- Verify in Build Scan — Visual confirmation
Quick Diagnostics
Generate Build Scan
./gradlew assembleDebug --scan
Profile Build Locally
./gradlew assembleDebug --profile
# Opens report in build/reports/profile/
Build Timing Summary
./gradlew assembleDebug --info | grep -E "^\:.*"
# Or view in Android Studio: Build > Analyze APK Build
Build Phases
| Phase | What Happens | Common Issues |
|---|---|---|
| Initialization | settings.gradle.kts evaluated | Too many include() statements |
| Configuration | All build.gradle.kts files evaluated | Expensive plugins, eager task creation |
| Execution | Tasks run based on inputs/outputs | Cache misses, non-incremental tasks |
Identify the Bottleneck
Build scan → Performance → Build timeline
- Long configuration phase: Focus on plugin and buildscript optimization
- Long execution phase: Focus on task caching and parallelization
- Dependency resolution slow: Focus on repository configuration
12 Optimization Patterns
1. Enable Configuration Cache
Caches configuration phase across builds (AGP 8.0+):
# gradle.properties
org.gradle.configuration-cache=true
org.gradle.configuration-cache.problems=warn
2. Enable Build Cache
Reuses task outputs across builds and machines:
# gradle.properties
org.gradle.caching=true
3. Enable Parallel Execution
Build independent modules simultaneously:
# gradle.properties
org.gradle.parallel=true
4. Increase JVM Heap
Allocate more memory for large projects:
# gradle.properties
org.gradle.jvmargs=-Xmx4g -XX:+UseParallelGC
5. Use Non-Transitive R Classes
Reduces R class size and compilation (AGP 8.0+ default):
# gradle.properties
android.nonTransitiveRClass=true
6. Migrate kapt to KSP
KSP is 2x faster than kapt for Kotlin:
// Before (slow)
kapt("com.google.dagger:hilt-compiler:2.51.1")
// After (fast)
ksp("com.google.dagger:hilt-compiler:2.51.1")
7. Avoid Dynamic Dependencies
Pin dependency versions:
// BAD: Forces resolution every build
implementation("com.example:lib:+")
implementation("com.example:lib:1.0.+")
// GOOD: Fixed version
implementation("com.example:lib:1.2.3")
8. Optimize Repository Order
Put most-used repositories first:
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
google() // First: Android dependencies
mavenCentral() // Second: Most libraries
// Third-party repos last
}
}
9. Use includeBuild for Local Modules
Composite builds are faster than project() for large monorepos:
// settings.gradle.kts
includeBuild("shared-library") {
dependencySubstitution {
substitute(module("com.example:shared")).using(project(":"))
}
}
10. Enable Incremental Annotation Processing
# gradle.properties
kapt.incremental.apt=true
kapt.use.worker.api=true
11. Avoid Configuration-Time I/O
Don't read files or make network calls during configuration:
// BAD: Runs during configuration
val version = file("version.txt").readText()
// GOOD: Defer to execution
val version = providers.fileContents(file("version.txt")).asText
12. Use Lazy Task Configuration
Avoid create(), use register():
// BAD: Eagerly configured
tasks.create("myTask") { ... }
// GOOD: Lazily configured
tasks.register("myTask") { ... }
Common Bottleneck Analysis
Slow Configuration Phase
Symptoms: Build scan shows long "Configuring build" time
Causes & Fixes:
| Cause | Fix |
|---|---|
| Eager task creation | Use tasks.register() instead of tasks.create() |
| buildSrc with many dependencies | Migrate to Convention Plugins with includeBuild |
| File I/O in build scripts | Use providers.fileContents() |
| Network calls in plugins | Cache results or use offline mode |
Slow Compilation
Symptoms: :app:compileDebugKotlin takes too long
Causes & Fixes:
| Cause | Fix |
|---|---|
| Non-incremental changes | Avoid build.gradle.kts changes that invalidate cache |
| Large modules | Break into smaller feature modules |
| Excessive kapt usage | Migrate to KSP |
| Kotlin compiler memory | Increase kotlin.daemon.jvmargs |
Cache Misses
Symptoms: Tasks always rerun despite no changes
Causes & Fixes:
| Cause | Fix |
|---|---|
| Unstable task inputs | Use @PathSensitive, @NormalizeLineEndings |
| Absolute paths in outputs | Use relative paths |
Missing @CacheableTask | Add annotation to custom tasks |
| Different JDK versions | Standardize JDK across environments |
CI/CD Optimizations
Remote Build Cache
// settings.gradle.kts
buildCache {
local { isEnabled = true }
remote<HttpBuildCache> {
url = uri("https://cache.example.com/")
isPush = System.getenv("CI") == "true"
credentials {
username = System.getenv("CACHE_USER")
password = System.getenv("CACHE_PASS")
}
}
}
Gradle Enterprise / Develocity
For advanced build analytics:
// settings.gradle.kts
plugins {
id("com.gradle.develocity") version "3.17"
}
develocity {
buildScan {
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
termsOfUseAgree.set("yes")
publishing.onlyIf { System.getenv("CI") != null }
}
}
Skip Unnecessary Tasks in CI
# Skip tests for UI-only changes
./gradlew assembleDebug -x test -x lint
# Only run affected module tests
./gradlew :feature:login:test
Android Studio Settings
File → Settings → Build → Gradle
- Gradle JDK: Match your project's JDK
- Build and run using: Gradle (not IntelliJ)
- Run tests using: Gradle
File → Settings → Build → Compiler
- Compile independent modules in parallel: ✅ Enabled
- Configure on demand: ❌ Disabled (deprecated)
Verification Checklist
After optimizations, verify:
- Configuration cache enabled and working
- Build cache hit rate > 80% (check build scan)
- No dynamic dependency versions
- KSP used instead of kapt where possible
- Parallel execution enabled
- JVM memory tuned appropriately
- CI remote cache configured
- No configuration-time I/O
References
FAQ
What does the gradle-build-performance skill do?
Debug and optimize Android/Gradle build performance. Use when builds are slow, investigating CI/CD performance, analyzing build scans, or identifying compilation bottlenecks.
How do I install gradle-build-performance?
Run npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill gradle-build-performance in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/gradle-build-performance/ (personal) or .claude/skills/gradle-build-performance/ (project).
Which AI agents can use gradle-build-performance?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is gradle-build-performance safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains gradle-build-performance?
It is published by new-silvermoon in new-silvermoon/awesome-android-agent-skills. It has 783 recorded installs.
More from new-silvermoon/awesome-android-agent-skills
android-testing
new-silvermoon/awesome-android-agent-skills
Comprehensive testing strategy involving Unit, Integration, Hilt, and Screenshot tests.
compose-ui
new-silvermoon/awesome-android-agent-skills
Best practices for building UI with Jetpack Compose, focusing on state hoisting, detailed performance optimizations, and theming. Use this when writing or refactoring Composable functions.
android-gradle-logic
new-silvermoon/awesome-android-agent-skills
Expert guidance on setting up scalable Gradle build logic using Convention Plugins and Version Catalogs.
android-architecture
new-silvermoon/awesome-android-agent-skills
Expert guidance on setting up and maintaining a modern Android application architecture using Clean Architecture and Hilt. Use this when asked about project structure, module setup, or dependency injection.
kotlin-concurrency-expert
new-silvermoon/awesome-android-agent-skills
Kotlin Coroutines review and remediation for Android. Use when asked to review concurrency usage, fix coroutine-related bugs, improve thread safety, or resolve lifecycle issues in Kotlin/Android code.
compose-performance-audit
new-silvermoon/awesome-android-agent-skills
Audit and improve Jetpack Compose runtime performance from code review and architecture. Use when asked to diagnose slow rendering, janky scrolling, excessive recompositions, or performance issues in Compose UI.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.