Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the Invalidate Caches/Restart do in Android Studio?

I have seen many answers suggest that one should Invalid Caches/Restart in order to improve the performance of Android Studio, whether it's memory or CPU. It also can be used to set up correct themes. I was wondering what it actually does though, since it seems to be the solution to so many problems.

like image 317
Henry Zhu Avatar asked Aug 07 '15 18:08

Henry Zhu


People also ask

What does invalidate caches do?

Invalidate Cache clears project structure related information (only) cached by Android studio.

What is cache flush and cache invalidate?

Invalidation of a cache or cache line means to clear it of data. This is done by clearing the valid bit of one or more cache lines. The cache must always be invalidated after reset as its contents will be undefined. If the cache contains dirty data, it is generally incorrect to invalidate it.

Can I delete Android studio cache?

If the user needs to delete any library cache of a project, they have to traverse through the . gradle/cache/modules-2/files-2.1 and . gradle/cache/modules-2/metadata-x.


2 Answers

Android Studio makes a lot of files as caches and does not delete them. This can cause trouble when there is a need to make new files, so clearing caches will clear the old cache and make Android Studio faster.

like image 187
DevUt Avatar answered Sep 24 '22 08:09

DevUt


Invalidate Cache clears project structure related information (only) cached by Android studio. Please note that this cache is different from "Build Cache" and "Gradle cache" briefly explained below.

Build Cache - stores certain outputs that the Android plugin for Gradle generates when building your project e.g. unpackaged AARs and pre-dexed remote dependencies. Build cache is enabled by default in recent plugins (2.3.0+).

Build Cache path: C:\Users\[User_Name]\.android\build-cache\gradleVersion

Here version value is driven by value defined in build.gradle file in your project. e.g. classpath "com.android.tools.build:gradle:$gradleVersion" Invalidate Cache has no impact on Build Cache. It can be cleared using "gradlew cleanBuildCache" command instead.

Gradle Cache - maintains Download Dependencies.

Gradle Cache path: C:\Users[user_name]\.gradle\caches\modules-2\files-2.1 [Windows] ~/.gradle/caches/modules-2/files-2.1 [Mac]

Also, as mentioned by @anurag, Clean Project has no relation to Build Cache.

More @ https://developer.android.com/studio/build/build-cache

like image 24
Birender Singh Avatar answered Sep 25 '22 08:09

Birender Singh