1. android studio默认缓存路径
Android studio缓存路径默认设置在C盘的
C:\Users\{用户名}\
,这样很容易导致占用C盘过多的空间, 可以把android studio的缓存路径设置到别的盘符下,释放C盘的空间,android studio主要包括.android,android studiox.x和.gradle这3个文件夹
-
.android
文件夹是存放android
虚拟机相关的文件夹 -
.AndroidStudiox.x
存放android studio
相关的配置 -
.gradle
是存储gradle
相关的配置和本地缓存
2.下面将分别介绍如何修改这些缓存文件夹的路径
2.1 修改.android
文件夹
-
1.添加ANDROID_SDK_HOME环境变量,设置自己自定义目录:M:\cache
-
2.修改新路径(
M:\cache\.android\avd
)下的xxx.ini文件内的路径信息,修改完成需要重启生效。
# 原来目录下配置信息
avd.ini.encoding=UTF-8
path=C:\Users\{用户名}\.android\avd\Pixel_XL_API_27.avd # 主要修改这个
path.rel=avd\Pixel_XL_API_27.avd
target=android-27
#修改后的配置信息
avd.ini.encoding=UTF-8
path=M:\cache\.android\avd\Pixel_XL_API_27.avd
path.rel=avd\Pixel_XL_API_27.avd
target=android-27
2.2 修改 .AndroidStudio*.*
文件夹
进入android studio
安装目录的bin
文件夹,打开idea.properties
文件,找到idea.config.path
,idea.system.path
,idea.plugins.path
,idea.log.path
修改这4个配置项。把${user.home}
替换为自己的路径:M:\cache\
,并把前面的#
去掉。
# 默认配置
#---------------------------------------------------------------------
# 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}/.AndroidStudio/config
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE system folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.system.path=${user.home}/.AndroidStudio/system
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.plugins.path=${idea.config.path}/plugins
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.log.path=${idea.system.path}/log
#---------------------------------------------------------------------
#修改后配置
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE config folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.config.path=M:/cache/.AndroidStudio/config
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE system folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.system.path==M:/cache/.AndroidStudio/system
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.plugins.path=${idea.config.path}/plugins
# 如果插件下载后重启,导致消失,则把`idea.plugins.path`值改成`${idea.system.path}/plugins`,
# 即`idea.plugins.path=${idea.system.path}/plugins`
# 因为插件下载是在`system`下,如果是zip格式则需要解压,安装则在`config`目录下
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.log.path=${idea.system.path}/log
#---------------------------------------------------------------------
3.修改.gradle
文件夹
进入android studio
安装目录的bin
文件夹,打开idea.properties
文件,在文件中添加:gradle.user.home=M:/cache/.gradle
#修改后配置
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE config folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.config.path=M:/cache/.AndroidStudio/config
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE system folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.system.path==M:/cache/.AndroidStudio/system
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.plugins.path=${idea.config.path}/plugins
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.log.path=${idea.system.path}/log
# gradle 目录配置
gradle.user.home=M:/cache/.gradle
#---------------------------------------------------------------------
最后打开工程,在Settings->Build,Execution,Deployment->Gradle修改Gradle user home: M:/cache/.gradle