DEV Community

Cover image for Deep Clean Your Android Studio to Fix Weird Issues
Vincent Tsen
Vincent Tsen

Posted on • Edited on • Originally published at vtsen.hashnode.dev

Deep Clean Your Android Studio to Fix Weird Issues

Apart from fixing the weird issues, it also helps to clean up your disk spaces!

I have encountered quite numbers of weird compilation and some run-time issues. I wonder is this very common to Android developer in their day-to-day work?

These are the steps I usually do to resolve them:

1. Clean Project

The first thing I do is "Build -> Rebuild Project". It is similar as "Build -> Clean Project" and "Build -> Make Project". Sometimes it works and sometimes it doesn't work.

deep_clean_android_studio_01.gif

2. Invalidate Caches

If "Clean Project" doesn't work, I will try "File -> Invalidate Caches / Restart ..."

deep_clean_android_studio_02.gif

Both steps work 99% of the time until I see this type of error indicating something wrong with the cache in the .gradle folder.

deep_clean_android_studio_03.PNG

3. Delete .gradle Folder

So I go to the user home directory and delete the .gradle folder, then the issue is resolved. This folder can be safely deleted, and it may be better if you close Android Studio before deleting it.

The folder is very big! So it can also save you a lot of disk spaces. Mine one is 10G bytes.

Your project folder also have the .gradle folder. I haven't encountered any issues yet that I need to delete it.

Summary

Well, these are the 3 steps I always do when I encounter weird errors. The last step "delete .gradle" folder is not usual, but it helps to save disk spaces. Maybe it is good to clean this up once a while?

The second step "Invalidate Caches" is less usual than the first step - "Clean Project" which is my daily routine in Android development.


Originally published at https://vtsen.hashnode.dev.

Top comments (0)