Skip to content
Latchkey

gradle --offline: Usage & Common CI Errors

Build using only the dependency cache - no network calls.

--offline is the Gradle flag that runs the build without any network access, resolving every dependency from the local cache. It makes builds hermetic and immune to registry outages, but fails if anything needed is not already cached.

What it does

In offline mode Gradle never contacts remote repositories; it uses only ~/.gradle/caches. This requires a prior online build (or a restored cache) that already downloaded every dependency the build needs.

Common usage

Terminal
./gradlew build            # online, warms the cache
./gradlew build --offline  # subsequent hermetic build
./gradlew test --offline

Common error in CI (and the fix)

Symptom: "No cached version of com.example:lib:1.2.3 available for offline mode." Cause: the dependency was never downloaded into the cache before going offline. Fix: run one online build (or restore a populated ~/.gradle/caches from the CI cache) so every dependency is present, then run with --offline; cache ~/.gradle between CI runs to keep it warm.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →