android – How to clear gradle cache?

android – How to clear gradle cache?

Gradle cache is located at

  • On Windows: %USERPROFILE%.gradlecaches
  • On Mac / UNIX: ~/.gradle/caches/

You can browse to these directory and manually delete it or run

rm -r $HOME/.gradle/caches/

on UNIX system. Run this command will also force to download dependencies.


Clear the Android build cache of current project

NOTE: Android Studios File > Invalidate Caches / Restart doesnt clear the Android build cache, so youll have to clean it separately.

On Windows:

gradlew cleanBuildCache

On Mac or UNIX:

./gradlew cleanBuildCache


This article Put your Android Studio on a diet gives more details on Android Studio caches

As @Bradford20000 pointed out in the comments, there might be a file as well as global gradle scripts located under $HOME/.gradle. In such case special attention must be paid when deleting the content of this directory.

The .gradle/caches directory holds the Gradle build cache. So if you have any error about build cache, you can delete it.

The –no-build-cache option will run gradle without the build cache.

Daemon on MS Windows
If youre on Windows, youll need to kill the daemon before it allows you to clear those directories. See Kill all Gradle Daemons Regardless Version? for more info.

android – How to clear gradle cache?


cleanBuildCache no longer works.

Android Gradle plugin now utilizes Gradle cache feature


Clean the cache directory to avoid any hits from previous builds

 rm -rf $GRADLE_HOME/caches/build-cache-*

Other digressions: see here (including edits).


Newest solution using Gradle task:


Available via Android plugin for Gradle, revision 2.3.0 (February 2017)


  1. Gradle 3.3 or higher.
  2. Build Tools 25.0.0 or higher.

More info at:


Build cache
Stores certain outputs that the Android plugin generates when building your project (such as unpackaged AARs and pre-dexed remote dependencies). Your clean builds are much faster while using the cache because the build system can simply reuse those cached files during subsequent builds, instead of recreating them. Projects using Android plugin 2.3.0 and higher use the build cache by default. To learn more, read Improve Build Speed with Build Cache.

NOTE: The cleanBuildCache task is not available if you disable the build cache.



gradlew cleanBuildCache

Linux / Mac:

gradle cleanBuildCache

Android Studio / IntelliJ:

gradle tab (default on right) select and run the task or add it via the configuration window 

NOTE: gradle / gradlew are system specific files containing scripts. Please see the related system info how to execute the scripts:

Leave a Reply

Your email address will not be published.