Skip to content
Aqib Javed.
All guides

Developer guide · Windows and Mac

How to clear the Gradle cache safely

By Aqib Javed · Updated Nov 2, 2026

Stop the Gradle daemons first (./gradlew --stop, or gradle --stop), close Android Studio, then delete the caches folder in the Gradle user home: ~/.gradle/caches on Mac and Linux, %USERPROFILE%\.gradle\caches on Windows, or wherever GRADLE_USER_HOME points. It's safe: Gradle downloads dependencies and rebuilds the rest on the next build, which is slower and needs internet. Stackyard, a free app, lists these folders and moves them to the Trash or Recycle Bin.

Where the Gradle cache is

  • Mac and Linux: ~/.gradle in your home folder.
  • Windows: %USERPROFILE%\.gradle, for example C:\Users\you\.gradle.
  • If the GRADLE_USER_HOME environment variable is set, the Gradle user home is there instead. Don't confuse it with GRADLE_HOME, which is where a Gradle installation lives.
  • Each project also has its own .gradle folder at its root (android/.gradle in a Flutter or React Native app) and build folders for its output. Those belong to the project, not the shared cache.

What's in ~/.gradle, and what's safe to delete

  • caches: downloaded dependencies, artifact transforms, the build cache and per-version caches. Safe to delete, and usually the biggest folder.
  • wrapper/dists: one folder per Gradle version the wrapper downloaded, such as gradle-8.10.2-all. Safe; each project downloads its version again on its next build.
  • daemon: the daemon registry and logs. Safe once the daemons are stopped.
  • native: native libraries Gradle extracts for its own use. Safe; it comes back.
  • jdks: JDKs Gradle downloaded for toolchains. A build only gets them back if it's set up to download toolchains, so leave this folder if you're not sure.
  • Keep gradle.properties and init.d. They hold your own settings, and gradle.properties can hold signing passwords or repository credentials.

How to clear the Gradle cache on Mac or Linux

Quit Android Studio or IntelliJ, then stop the daemons so nothing holds files open. --stop only stops daemons of the Gradle version you run it with; if a delete fails because files are in use, the jps command from the JDK lists every GradleDaemon process so you can end it, or restart. Deleting caches alone is enough for most problems; the last line is a full reset.

cd ~/path/to/project && ./gradlew --stop   # or: gradle --stop
du -sh ~/.gradle/*                         # see what takes the space
rm -rf ~/.gradle/caches
rm -rf ~/.gradle/wrapper/dists ~/.gradle/daemon ~/.gradle/native

How to clear the Gradle cache on Windows

Close Android Studio, then run this in PowerShell from any project that has a Gradle wrapper. In Command Prompt, rd /s /q "%USERPROFILE%\.gradle\caches" does the same. If Windows says a file is in use, a Java process is still running: end it in Task Manager or restart, then delete again.

cd C:\path\to\project
.\gradlew --stop
Remove-Item -Recurse -Force "$env:USERPROFILE\.gradle\caches"
Remove-Item -Recurse -Force "$env:USERPROFILE\.gradle\wrapper\dists", "$env:USERPROFILE\.gradle\daemon"

Lighter options: clean, refresh and automatic cleanup

  • ./gradlew clean deletes one project's build output. It doesn't touch the shared cache in ~/.gradle.
  • ./gradlew build --refresh-dependencies makes Gradle ignore its cached entries and check every dependency against the repositories again. Files that haven't changed aren't downloaded again, so try this first when a dependency looks stale or broken.
  • Gradle already trims the cache by itself, at most once a day. The current Gradle docs list the defaults: downloaded dependencies unused for 30 days, created files such as transforms and the build cache unused for 7 days, and released wrapper distributions unused for 30 days. An init script in ~/.gradle/init.d can change those periods.
  • In Android Studio, File > Invalidate Caches clears the IDE's own caches and indexes, not the Gradle cache.

Clearing it with Stackyard

Stackyard is a free, open-source app for Windows and Mac. Its Gradle page lists each wrapper distribution by version, plus the caches, daemon and native folders in your Gradle user home (it follows GRADLE_USER_HOME), with their sizes. Its project cleanup finds project .gradle and build folders and groups the projects you haven't touched in three months or more. You see every step before it runs, and removals go to the Trash or Recycle Bin, so they can be undone.

Questions

Is it safe to delete the Gradle caches folder?

Yes. ~/.gradle/caches only holds things Gradle can download or rebuild. The next build takes longer and needs a network connection; an offline build fails until the cache is filled again.

Where is the Gradle cache on Windows?

In %USERPROFILE%\.gradle\caches, for example C:\Users\you\.gradle\caches, unless GRADLE_USER_HOME points somewhere else.

How do I clear the Gradle cache in Android Studio?

Android Studio has no button for the shared Gradle cache. Close it, run gradlew --stop in a terminal, and delete the caches folder in your Gradle user home. File > Invalidate Caches only clears the IDE's own caches.

Does flutter clean clear the Gradle cache?

No. flutter clean deletes the project's build output; the shared cache in ~/.gradle stays. Delete that yourself if you need a full reset.

Can I change the Gradle cache location?

Yes. Set the GRADLE_USER_HOME environment variable to the new folder, for example D:\gradle, then open a new terminal and restart Android Studio. Gradle fills the new folder on the next build, and you can delete the old one.