Toolkit: Android Studio, Build Analyzer & Gradle Profiler
The command line is what CI runs, but finding why a build is slow, big or broken is often faster with the right tool. This page maps the tools around Android builds, by job.
Android Studio
| Feature | Where | Use it for |
|---|---|---|
| Build Variants panel | View → Tool Windows → Build Variants | switching the active variant (freeDebug, paidRelease) for the editor and Run |
| Merged Manifest tab | open AndroidManifest.xml, tab at the bottom |
the merger's result with each line coloured by source file (The Manifest Merger) |
| APK Analyzer | Build → Analyze APK…, or drag an APK/AAB in | the GUI for apkanalyzer: sizes, dex tree with method counts, compare two APKs |
| Build Analyzer | Build window → Build Analyzer after a build | tasks that dominate build time, plugins responsible, tasks that always run, configuration cache compatibility, non-cacheable tasks, and Jetifier/download checks |
| AGP Upgrade Assistant | Tools → AGP Upgrade Assistant | step-by-step AGP migrations (DSL renames, namespace, buildConfig opt-in) |
| Gradle Sync | toolbar | imports the Gradle model into the IDE; sync errors are configuration errors, the same ones ./gradlew help shows |
Android Studio uses the project's own Gradle wrapper and the JDK set in Settings → Build Tools → Gradle → Gradle JDK. When the IDE and CI disagree, compare those two first.
Measuring builds
| Tool | What it gives | Offline? |
|---|---|---|
--profile |
an HTML report: configuration, dependency resolution and per-task times | yes |
Build Scans (--scan) |
timeline, cache hits/misses with reasons, dependency insight, test results; shareable link | uploads to scans.gradle.com or a Develocity server |
| Gradle Profiler | repeatable benchmarks of scenarios (clean build, incremental change, ABI change) with warm-up runs; can drive async-profiler/JFR | yes (separate install) |
| Build Analyzer | the IDE's view of a single build | yes |
--profile works anywhere, including this course's container:
mkdir -p hello/app/src/main && cd hello
cat > settings.gradle.kts <<'KTS'
pluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } }
dependencyResolutionManagement { repositories { google(); mavenCentral() } }
rootProject.name = "hello"
include(":app")
KTS
echo 'plugins { id("com.android.application") version "9.4.1" apply false }' > build.gradle.kts
echo '<manifest xmlns:android="http://schemas.android.com/apk/res/android"><application android:label="Hello" /></manifest>' > app/src/main/AndroidManifest.xml
cat > app/build.gradle.kts <<'KTS'
plugins { id("com.android.application") }
android {
namespace = "com.example.hello"
compileSdk = 36
defaultConfig { applicationId = "com.example.hello"; minSdk = 24; targetSdk = 36; versionCode = 1; versionName = "1.0" }
}
KTS
gradle wrapper > /dev/null
./gradlew -q assembleDebug --profile
ls build/reports/profile/ | sed -E 's/[0-9]{4}(-[0-9]{2}){5}/<timestamp>/'
grep -oE '<a href="#tab[0-9]">[^<]*</a>' build/reports/profile/*.html | sed -E 's/<[^>]*>//g'css
js
profile-<timestamp>.html
Summary
Configuration
Dependency Resolution
Artifact Transforms
Task Execution
The report's tabs answer the first triage question: is the time going into configuration (too much work in build scripts, too many variants: try the configuration cache and variant filters), dependency resolution (slow repositories, dynamic versions), or task execution (look at the slowest tasks, then at the build cache)? The Artifact Transforms tab shows time AGP spends transforming dependencies (dexing and desugaring library jars, for example), which the build cache also helps with.
Gradle Profiler scenarios
# performance.scenarios (run: gradle-profiler --benchmark --scenario-file performance.scenarios)
clean_build {
tasks = ["assembleFreeDebug"]
cleanup-tasks = ["clean"]
gradle-args = ["--build-cache"]
warm-ups = 2
iterations = 5
}
incremental_java_change {
tasks = ["assembleFreeDebug"]
apply-non-abi-change-to = ["app/src/main/java/com/example/hello/MainActivity.java"]
warm-ups = 2
iterations = 5
}Benchmarks with warm-ups and several iterations are the only honest way to say "AGP 9.4 made our builds 12% faster" or "this convention plugin costs 3 s of configuration".
Static analysis and dependencies
| Tool | For |
|---|---|
Android Lint (./gradlew lintFreeRelease) |
API-level misuse, missing translations, security checks; lintVitalRelease runs before release builds. (Not seeded in this course's container.) |
./gradlew :app:dependencies --configuration freeReleaseRuntimeClasspath |
the resolved graph (Dependencies & Unit Tests) |
./gradlew :app:dependencyInsight --dependency kotlin-stdlib --configuration freeReleaseRuntimeClasspath |
why a version was chosen |
| Dependency Analysis Gradle Plugin | unused and misdeclared (api vs implementation) dependencies |
Gradle dependency verification (gradle/verification-metadata.xml) |
checksums/signatures of every downloaded artifact |
Command-line tools from the SDK
| Tool | Package | Lesson |
|---|---|---|
sdkmanager, avdmanager |
cmdline-tools | The Android Toolchain |
apksigner, zipalign |
build-tools | Verifying APKs |
aapt2, dexdump, d8 |
build-tools | Inspecting APKs |
apkanalyzer, retrace, r8 |
cmdline-tools | Keep Rules & Retrace |
bundletool |
separate jar (also inside AGP) | App Bundles |
adb |
platform-tools | installing and debugging on devices |
Test yourself
The --profile report shows most time in the Configuration tab. Which change is most likely to help?
- A bigger build cache
- The configuration cache and fewer variants (variant filters)
- More R8 rules
- zipalign
Why use Gradle Profiler instead of timing one build by hand?
- It makes builds faster
- It runs warm-ups and several iterations of defined scenarios, giving repeatable numbers
- It's required by AGP
- It uploads results to Play
Which tool answers "why did Gradle pick this version of a library?"
- apkanalyzer
- dependencyInsight
- signingReport
- retrace