How to delete Gradle cache files

If, like me, you are having troubles compiling projects (also Android Studio ones) after having upgraded Gradle you can try to delete cache files. I'm assuming you are working on a Linux box and that your Android projects are saved inside  ~/AndroidStudioProjects/
  • How to delete general caches:
    find ~/.gradle -wholename '*/caches/*' -type d -maxdepth 2 -exec rm -r {} \;
    find ~/.gradle -wholename '*/daemon/*' -type d -maxdepth 2 -exec rm -r {} \;
  • How to delete Android Studio caches:
    find ~/AndroidStudioProjects/ -wholename '*/.gradle/*' -type d -maxdepth 3 -exec rm -r {} \;
    I hope these commands will help you!