Guide

How to clear Gradle cache on Mac, without breaking builds.

Gradle keeps downloaded dependencies, transformed jars, and a full copy of every Gradle version your projects' wrappers ask for. All of it lives in one folder, and most of it is safe to clear.

The short version

Stop the Gradle daemon with ./gradlew --stop, then move ~/.gradle/caches to the Trash. Gradle downloads dependencies again on the next build. For old Gradle versions, move folders you don't need out of ~/.gradle/wrapper/dists. Leave ~/.gradle/gradle.properties and init.d alone: those are your settings. Each project's own build folder clears with ./gradlew clean.

Gradle cache location on Mac

Gradle keeps everything in its user home, ~/.gradle, unless GRADLE_USER_HOME points somewhere else. The same folder serves the command line, Android Studio, and IntelliJ IDEA.

WhatDefault locationOn one Mac
Dependencies and transforms~/.gradle/cachesNot installed on the Mac we measured
Gradle versions for the wrapper~/.gradle/wrapper/distsNot installed on the Mac we measured
Daemon logs~/.gradle/daemonNot installed on the Mac we measured
Each project's build outputyour-project/buildPer project

Gradle isn't installed on the Mac this page was written on, so there are no measured sizes here. Check yours with:

du -sh ~/.gradle/* 2>/dev/null | sort -h

What's safe to delete in ~/.gradle

  • caches: safe. Downloaded dependencies in modules-2, transformed jars, the local build cache, and per-version script caches. Gradle downloads or rebuilds what it needs. The first build afterward is slow, and it needs a network connection.
  • wrapper/dists: safe, folder by folder. One full Gradle distribution for each version a project's wrapper asked for, each a hundred megabytes or more. Delete versions no current project uses; ./gradlew downloads its version again if needed.
  • daemon: safe. Logs from background Gradle processes.

Keep gradle.properties (often with signing keys or repository credentials) and init.d (init scripts). They aren't cache.

How to clear Gradle cache, step by step

  1. Stop the daemon. Run ./gradlew --stop in a project, or gradle --stop. Quit Android Studio too. A running daemon keeps files in the cache open.
  2. Clear project build folders, if you want. ./gradlew clean deletes the current project's build folder.
  3. Move the cache to the Trash. In Terminal, mv ~/.gradle/caches ~/.Trash/gradle-caches, or open ~/.gradle in Finder with Go › Go to Folder. It's hidden, so type the path.
  4. Build once. Run your usual build while online. If it succeeds, empty the Trash.

To force fresh dependencies without deleting anything, ./gradlew build --refresh-dependencies checks every dependency against its repository again. It's the better fix when one library looks stale.

How big the Gradle cache gets

On an Android developer's Mac, several gigabytes is normal, and 10 GB or more is common after a few years, because each Android Gradle Plugin and Gradle upgrade brings a new set of transformed files. Gradle cleans the cache on a schedule by default, removing downloaded files unused for 30 days and files it created itself after 7 days; since Gradle 8 you can change those limits in an init script. Old Gradle versions' folders still pile up when no project uses them anymore.

Android projects have more: the Android SDK in ~/Library/Android/sdk, with system images for every emulator you've made, and the emulators themselves in ~/.android/avd. Delete those from Android Studio's SDK Manager and Device Manager rather than Finder.

Also on the JVM? Maven keeps its downloads in ~/.m2/repository. More caches: Cargo, Go, or every tool.

Disk Forecast finds this for you

Disk Forecast lists ~/.gradle/caches and ~/.gradle/wrapper/dists under Cleanup › Safe to clear › Package manager caches. A project's build folder shows up as a Gradle build only when a build.gradle or build.gradle.kts sits beside it, so a random folder named build is never listed: under Build folders in old projects after 30 days without changes, or Build folders in active projects before that. Everything goes to the Trash. It's free.

Questions

How do I clear the Gradle cache?

Stop the daemon with ./gradlew --stop, quit Android Studio, then delete or move ~/.gradle/caches to the Trash. Gradle downloads dependencies again on the next build, which needs a network connection.

Where is the Gradle cache located on a Mac?

In ~/.gradle/caches, inside Gradle's user home. Set GRADLE_USER_HOME to move it. Wrapper downloads of Gradle itself are in ~/.gradle/wrapper/dists.

Is it safe to delete ~/.gradle?

Mostly. caches, wrapper/dists, and daemon can all go. Keep gradle.properties and init.d if you have them: they're your settings, and gradle.properties may hold credentials.

Does ./gradlew clean clear the Gradle cache?

No. It deletes the current project's build folder. The shared cache in ~/.gradle/caches stays. To refetch dependencies without deleting the cache, use --refresh-dependencies.

Know before it's full.

Free. No account, no subscription.

macOS 14 or later · Apple Silicon and Intel · brew install --cask coreyhaines31/tap/diskforecast