Gradle Cache on Mac: Is ~/.gradle/caches Safe to Delete?
Medium riskPackage managers & build toolsUpdated
- Location
~/.gradle/caches
- Risk level
- Medium riskSafe to remove, but the tool that owns it re-downloads or rebuilds it on next use, which costs time and bandwidth. Listed, never pre-selected.
- Selected by default
- No — you choose whether to include it
- What Freshist does
- Moves the selected items to the Trash, so you can undo. Nothing is deleted outright.
- In the app
- Clean → Gradle Cache — “Build cache — next Gradle builds re-download dependencies.”
From Freshist's own cleaning rules — the same catalog the app uses.
What lives in ~/.gradle/caches
Gradle keeps its shared state in the Gradle user home, ~/.gradle unless GRADLE_USER_HOME says otherwise. The caches folder inside it is used by every build on your Mac, from the command line or from Android Studio and IntelliJ IDEA.
| Folder | What it holds |
|---|---|
modules-2/ | Dependencies downloaded from Maven Central, Google's Maven repository and others, plus their metadata |
transforms-*/ | Artifacts Gradle has transformed, such as Android libraries processed for compilation |
build-cache-1/ | The local build cache: task outputs reused across builds and branches |
jars-*/, <version>/ | Per-Gradle-version caches for compiled build scripts and plugins |
The full layout is in the Gradle directory layout docs. Two neighbours are often large too: ~/.gradle/wrapper/dists, which holds whole Gradle distributions downloaded by the wrapper, and ~/.gradle/daemon, which holds daemon logs.
Why Android projects make it huge
Every Gradle version you've used keeps its own versioned folders, and Android projects bring hundreds of dependencies plus heavy transforms. Switching branches, upgrading the Android Gradle Plugin, or opening sample projects all add more.
Gradle does clean up on its own. Per the docs, unused downloaded resources are removed after 30 days by default, and resources Gradle created itself (like transforms) after 7 days. Versioned caches for Gradle versions you no longer run are cleaned up too. The docs say these caches normally need no manual management, but cleanup only runs when Gradle itself runs, and it doesn't cover projects you've stopped opening for good.
What happens if you delete it
- The next build downloads every dependency again. For a large Android app that's a lot of data and can take many minutes.
- Transforms and the local build cache are recomputed, so the first build is a full, uncached build.
--offlinebuilds fail until the dependencies are back.- Project files,
build.gradle(.kts), version catalogs, and yourgradle.propertiesaren't touched. - Project-level
build/folders and.gradle/folders inside projects are separate; delete those per project if you want.
Size it up
du -sh ~/.gradle/caches ~/.gradle/wrapper/dists ~/.gradle/daemon 2>/dev/null
du -sh ~/.gradle/caches/* | sort -h | tail
ls ~/.gradle/wrapper/dists # Gradle versions downloaded by the wrapper
Clear it safely
Gradle has no single "clear cache" command, so clearing means deleting the folder with nothing running:
- Stop the daemons: run
./gradlew --stopin a project (orgradle --stop), and quit Android Studio or IntelliJ IDEA. - Delete
~/.gradle/caches. Optionally delete old versions under~/.gradle/wrapper/distsand the~/.gradle/daemonfolder. - Open the project and build or sync once to repopulate it.
Stopping the daemons matters. A running daemon holds locks on cache files and may write to them while they're being removed. If you only want Gradle's automatic cleanup to be more aggressive, Gradle 8 lets you set retention periods in an init script; see the cache cleanup section of the docs.
When not to clear it
Keep it if you're about to work offline, on a metered connection, or right before a release where a long cold build would hurt. Clear it after leaving Android or JVM work, after upgrading Gradle versions several times, or when a corrupt dependency causes errors that --refresh-dependencies doesn't fix. Maven keeps a separate repository in ~/.m2, covered in the Maven cache guide, and IDE caches are in JetBrains caches.
Sources
Frequently asked questions
Can I delete the whole ~/.gradle folder?
Better not. gradle.properties there can hold signing settings, proxy config and repository credentials, and init.d holds init scripts. Clear caches/, and optionally wrapper/dists and daemon/, but keep the files you or your team configured.
Does --refresh-dependencies do the same thing?
Not quite. ./gradlew build --refresh-dependencies tells Gradle to recheck remote repositories and update cached entries for that build. It doesn't free space; deleting the cache does.
Why does Android Studio sync take so long after clearing?
Sync resolves and downloads every dependency the project declares, including the Android Gradle Plugin and its own dependencies, then re-runs artifact transforms. The first sync after a cleared cache is a full download.