Gradle Profiler缓存策略及全量清洁构建时长测量相关问题
Let's break down your questions clearly—since measuring clean build times accurately depends on getting these cache behaviors right.
1. What's the Difference Between Build Cache and Transform Cache?
These are two distinct caching systems in the Gradle ecosystem, each serving a unique purpose:
Build Cache (Gradle Core)
This is Gradle's native caching layer that stores full task outputs. Think compiled.classfiles, packaged JAR/AARs, or processed resources that are direct results of Gradle tasks. It’s designed to reuse task results across builds and even projects—if a task’s inputs haven’t changed, Gradle skips executing the task entirely and pulls the cached output. The build cache is managed directly by Gradle’s incremental build logic.Transform Cache (AGP-Specific)
This is an Android-only cache maintained by the Android Gradle Plugin (AGP). It stores results of intermediate transformation steps that aren’t part of standard Gradle task outputs. Examples include resource compression, R8/ProGuard obfuscation, Jetpack Compose bytecode transformations, or dependency resolution tweaks. AGP uses this cache to avoid re-running expensive transformation logic when input files haven’t changed.
2. Do I Need to Manually Disable Remote Cache, or Does Gradle Profiler Do It Automatically?
Gradle Profiler does NOT automatically disable remote cache—you’ll need to handle this manually to get accurate clean build measurements.
Remote cache is a global Gradle configuration, and Profiler doesn’t modify your build settings by default. If remote cache is enabled, your profiling runs might pull pre-built results from a remote server, which would skew your "clean build" time (since you’re not truly building everything from scratch locally).
To disable remote cache for profiling:
- Add this line to your project’s
gradle.propertiesfile:org.gradle.caching.remote.enabled=false - Or, to keep your global config intact, specify it directly in your Gradle Profiler scenario file (e.g.,
profiler-scenarios.profile):scenarios: - name: clean_full_build tasks: ["clean", "assembleDebug"] gradle-properties: org.gradle.caching.remote.enabled: false
This ensures your profiling runs only use local (or no) cache, giving you reliable measurements of a full clean build.
内容的提问来源于stack exchange,提问作者Maksim Turaev

