Skip to content
Latchkey

Gradle Build Cache Errors - "Corrupted" / Cache Miss in CI

A Gradle build-cache entry is corrupt or stale, so a task either fails to unpack a cached output or produces wrong results. A partially-written cache (often from an interrupted CI run) is the usual culprit.

What this error means

Builds fail intermittently with a cache-unpack error, or a task is incorrectly marked FROM-CACHE and produces stale outputs. Deleting the cache makes it pass, which points squarely at the cache.

gradle output
> Task :app:compileJava FROM-CACHE
> Could not load entry ... from the build cache:
  Cache entry 'a1b2c3...' is corrupt. Could not unpack.

Common causes

Partially written cache entry

An interrupted or OOM-killed build can leave a half-written entry in the local or remote build cache. Reading it later fails to unpack.

Non-reproducible task inputs

A task whose inputs are not fully declared can be served a stale cached output that no longer matches reality, producing wrong-looking results.

How to fix it

Clear the cache and rebuild clean

Remove the local build cache and force a fresh build to confirm the cache was the problem.

Terminal
rm -rf ~/.gradle/caches/build-cache-1
./gradlew clean build --no-build-cache

Key the CI cache so corruption cannot persist

Use a cache key that changes with build inputs, and avoid caching across interrupted runs.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.gradle/caches
    key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', 'gradle/wrapper/gradle-wrapper.properties') }}

How to prevent it

  • Avoid persisting the cache from interrupted/OOM-killed runs.
  • Ensure tasks fully declare inputs/outputs so caching stays correct.
  • Use a versioned cache key tied to build scripts and wrapper version.

Frequently asked questions

What causes "Build cache corruption"?
An interrupted or OOM-killed build can leave a half-written entry in the local or remote build cache. Reading it later fails to unpack.
How do I fix Build cache corruption?
Remove the local build cache and force a fresh build to confirm the cache was the problem.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card