gradle --refresh-dependencies: Usage & CI Errors
Bypass the dependency cache and re-resolve everything from remote.
--refresh-dependencies is a Gradle command-line flag that forces re-resolution of all dependencies, bypassing cached metadata and re-downloading artifacts. It is the fix for a build stuck on stale or corrupted cached dependency state.
What it does
The flag tells Gradle to ignore cached module metadata (and the TTL on changing/SNAPSHOT versions) and re-check the remote repositories, re-downloading anything whose checksum differs. It does not delete the cache; it revalidates it.
Common usage
./gradlew build --refresh-dependencies
./gradlew assemble --refresh-dependenciesCommon error in CI (and the fix)
Symptom: a build keeps using an old SNAPSHOT, or fails with a checksum/zip error on a cached artifact. Cause: Gradle served a stale or corrupted entry from ~/.gradle/caches. Fix: re-run with --refresh-dependencies to force re-download and revalidation; if a metadata file itself is corrupt, also clearing the specific module under ~/.gradle/caches/modules-2 resolves it.