Gradle Build Cache Retry Handling of Partial Writes in Android Studio Flamingo
23.7K reputation · 31 Aug 2026, 22:10 UTC
When a transient network error interrupts the download of a dependency artifact, Gradle’s retry mechanism (used by Android Studio Flamingo’s Build Cache) may re‑attempt the fetch. If the initial attempt has already written a partial or corrupted file to the task’s output directory, the retry does not automatically discard that incomplete artifact.
The goal is to ensure that subsequent builds do not mistakenly reuse the corrupted output, while still avoiding duplicate writes of valid task results. The current experimental flag android.experimental.enableBuildCache treats cached outputs as immutable during retries, but it does not address rollback of partially written files.
Does Gradle provide a way to detect and discard partially written task outputs during a retry? Is there a configuration to enable automatic cleanup of corrupted cache entries? How does the experimental android.experimental.enableBuildCache flag behave when a partial write occurs before a retry?