Gradle keeps downloaded dependencies, build caches, transformed jars and whole Gradle distributions in ~/.gradle. After a year of Android or Kotlin work it is often 5 to 20 GB, and more if you build several projects on different Gradle versions.
Where the Gradle cache is
du -sh ~/.gradle/caches ~/.gradle/wrapper/distsls ~/.gradle/caches ~/.gradle/wrapper/dists
caches/modules-2 holds downloaded dependencies, caches/build-cache-1 the build cache, and a folder per Gradle version (caches/8.10, caches/9.1) the caches of that version. wrapper/dists holds every Gradle version the wrapper downloaded, a few hundred MB each.
Doesn't Gradle clean up by itself?
Partly. Recent Gradle versions delete dependencies, version caches and wrapper distributions nobody used for 30 days. But that cleanup only runs when Gradle runs. Stop building a project, or move it to a new Gradle version, and what it left behind can stay. The build and .gradle folders inside your projects aren't covered at all.
How to clear the Gradle cache
Stop the daemons first, so nothing is writing to the cache:
./gradlew --stop# or, without a project at handpkill -f GradleDaemon
Then remove what you don't need. From mild to thorough:
# caches of Gradle versions you no longer use (keep your current one)rm -rf ~/.gradle/caches/7.*# wrapper distributions of those versionsrm -rf ~/.gradle/wrapper/dists/gradle-7.*# the build cacherm -rf ~/.gradle/caches/build-cache-1# everything: the next build downloads all dependencies againrm -rf ~/.gradle/caches
Don't delete ~/.gradle as a whole: gradle.properties in it can hold signing settings and credentials.
Clearing the whole cache is safe, but the next build is slow and needs the network. In Android Studio, File, Invalidate Caches clears the IDE's own caches, not Gradle's.
In your projects
Each project has a build folder per module and a .gradle folder. ./gradlew clean empties the build folders of one project. For all of them at once, see finding build folders across projects.
Or let Sluice do it
Sluice removes Gradle versions and caches no project used for a month, and waits while a Gradle build runs. Sluice is free to download and clean with; Pro cleans every night and whenever space runs low.
macOS 14 Sonoma or later · Apple silicon and Intel · or brew install --cask qraft/tap/sluice
More guides
- Xcode DerivedData: where it is and how to delete it safely
- "No space left on device" on a Mac: find what filled it and fix it
- Find and delete node_modules (and target, .venv, Pods) across all your projects
- A DevCleaner alternative for Macs that run more than Xcode
- A CleanMyMac alternative for developers