Configuration method of android studio to save C disk space

  • 2021-11-10 10:45:42
  • OfStack

Recently, it was found that there is not much free space left in C disk. After inspection, it was found that in

C:\Users\ < Computer user name > Under the directory of\, there are two folders with large space. These two folders are. AndroidStudioPreview3.2 (different versions of android studio names will be different) and. gradle, and AndroidStudioPreview3.2 stores cache files such as AndroidStudio configuration and plug-ins.
. gradle stores gradle configuration and related dependent files, which together have more than 2G space size.

It takes up the already tight C disk space. You can save C disk space by storing these two folders to other paths through the following operations.

1 Turn off android studio first.

Select a disk with sufficient free space, assuming it is D disk, create a new directory under D disk, and name it cacheadr.

Move the.AndroidStudioPreview3.2 and.gradle folders to the d:\ cacheadr directory.

2 Set the new storage path of androidstudio.

Go to the AndroidStudio software installation directory, enter the bin directory, edit the idea. properties file,

Add roughly 1 line below Line 8 as follows


idea.config.path=D:/cacheadr/.AndroidStudioPreview3.2/config

The file content after adding the content of this line is roughly as follows:


#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE config folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.config.path=${user.home}/.AndroidStudioPreview/config
idea.config.path=D:/cacheadr/.AndroidStudioPreview3.2/config

Then add the following line under line 13:


idea.system.path=D:/cacheadr/.AndroidStudioPreview3.2/system

3 Set the configuration of gradle and the new storage path of related dependent files.

The most effective method is to add a system variable named GRADLE_USER_HOME through the environment variable in the advanced settings in the windows system, and the value of this variable is: d:\ cacheadr\. gradle, which is the new directory where. gradle is stored.

Another way is to add this line to the gradle. bat batch file under the bin directory of gradle after the line content of set DEFAULT_JVM_OPTS=.


set GRADLE_OPTS="-Dgradle.user.home=D:\cacheadr\.gradle"  . 

This method has not been measured.

4 Reopen androidstudio, compile the application program, normal, and find that the disk space of C is reduced.

5 Reopen the previous project. If you find the previous normal project, many code pages display red to report errors.

For example, ActivityCompat in import android. support. v4. app. ActivityCompat shows red. The following methods can be adopted:

5.1 clear project in Build, removing previously compiled information.

5.2 Under the File menu, Invalidate Caches/Restart, select Invalidate and Restart to clear the cache in studio.

After reopening android studio, download and configure relevant tool information, it is found that the scarlet letter disappears and returns to normal.

Summarize


Related articles: