Guide
How to clear Gradle, Maven and Android Studio caches on a Mac
Android Studio, Gradle and Maven can fill a Mac with caches, SDK images and old versions. What each folder holds and how to clear it safely.
Updated 6 min read
Android and Java development fills a Mac in several places at once: Gradle and Maven caches, Android SDK system images, emulators, and settings and caches of every Android Studio version you have installed. Here is what each folder holds and how to clear it safely.
Gradle
Gradle keeps downloaded dependencies and build caches in ~/.gradle/caches, and downloaded Gradle versions in ~/.gradle/wrapper/dists. Gradle cleans some unused entries on its own, but caches of old Gradle versions and old wrapper distributions often stay.
- Stop running Gradle daemons:
./gradlew --stopin a project, orgradle --stop. - Delete the caches and old distributions:
rm -rf ~/.gradle/caches rm -rf ~/.gradle/wrapper/dists
The next build downloads what it needs. Leave ~/.gradle/gradle.properties in place if you have one.
Maven
Maven's local repository is ~/.m2/repository. Delete it to start fresh, or purge one project's dependencies from inside the project:
mvn dependency:purge-local-repository
Keep ~/.m2/settings.xml.
Android Studio
- Caches and logs:
~/Library/Caches/Google/AndroidStudio<version>and~/Library/Logs/Google/AndroidStudio<version>. Safe to delete while Android Studio is closed. - Old versions: each version you have used keeps its own folders, including
~/Library/Application Support/Google/AndroidStudio<version>. Keep the folders of the version you use and delete the ones for versions you have removed. - Invalidate Caches: File → Invalidate Caches rebuilds the IDE's caches and indexes. Use it to fix IDE problems, not to free space.
Android SDK and emulators
- The SDK is in
~/Library/Android/sdk. Emulator system images in itssystem-imagesfolder are often several gigabytes each. Remove the ones you don't use in Tools → SDK Manager, with Show Package Details turned on. - Emulators (AVDs) live in
~/.android/avd. Delete the ones you don't use in Device Manager, which removes their disk images too.
Kotlin Multiplatform
Kotlin/Native toolchains and dependencies are kept in ~/.konan, which can be several gigabytes. Delete it if you no longer build for Kotlin/Native; the next build downloads what it needs.
Find Gradle and Maven caches with Roomy
Roomy's Developer cleanup finds Gradle and Maven caches together with JetBrains IDE caches and more than a dozen other package manager caches, with each one's size. Your projects are never touched. For the npm, Homebrew and pip side of things, see how to clear npm, Yarn, pnpm, Bun and Homebrew caches.
Frequently asked questions
Is it safe to delete the .gradle folder?
The caches inside it, yes: Gradle downloads dependencies and rebuilds what it needs on the next build, which takes longer. Keep gradle.properties in ~/.gradle if you have one, because it can hold your settings and credentials.
Is it safe to delete ~/.m2/repository?
Yes. It is Maven's local copy of downloaded dependencies. Maven downloads them again on the next build. Keep settings.xml in ~/.m2, which holds your repository settings.
What does Invalidate Caches do in Android Studio?
It clears Android Studio's own caches and indexes and rebuilds them after a restart. It fixes many odd IDE problems, but it frees little space; the big folders are Gradle caches, emulator images and old Android Studio versions.