Search code examples
androidandroid-studiointellij-ideainvalidationandroid-studio-3.1.4

Android Studio - invalidate vs restart vs invalidate and restart


When you go to File -> Invalidate Caches/Restart you can see three options presented to you:

1) Invalidate

2) Just restart

3) Invalidate and restart

I usually choose option 3, but in which cases would you use one of the other two?


Solution

  • Invalidate and restart is what you need if something goes wrong (valid code highlighted as invalid, error highlighting/inspections stop working, code compiling while editor shows errors, compilation fails while editor thinks the code is OK, etc).

    You may want to use Invalidate without restart if you plan to finish some other things before restarting (like you are in the middle of the debug session or want to commit the changes to the version control first, or there is compilation in progress). There will be no effect from this action until you restart anyway. Basically, you are scheduling caches rebuild for the next IDE start.

    Just restart can be handy when you've finished the task after using the Invalidate action or just to restart the IDE to see if it fixes the issue without invalidating the caches (since caches rebuild can take a lot of time for large projects).