How to clear gradle cache?
Gradle cache is located at
- On Windows:
%USERPROFILE%\.gradle\caches
- 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.
UPDATE
Clear the Android build cache of current project
NOTE: Android Studio's File > Invalidate Caches / Restart
doesn't clear the Android build cache, so you'll have to clean it separately.
On Windows:
gradlew cleanBuildCache
On Mac or UNIX:
./gradlew cleanBuildCache
UPDATE 2
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 gradle.properties
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 you're on Windows, you'll need to kill the daemon before it allows you to clear those directories. See Kill all Gradle Daemons Regardless Version? for more info.