Gradle離線配置、.android、.AndroidStudio、.gradle、.m2快取資料夾路徑修改
build.gradle
repositories {
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
修改專案的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://dl.google.com/dl/android/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'https://dl.google.com/dl/android/maven2' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle離線配置
開啟專案一直卡在某個地方?如AndroidStudio匯入專案在 Building gradle project info 一直卡住,可能是因為AS在下載gradle,但是速度很慢。 離線配置gradle: 1.自行下載相應的gradle版本 通過專案根目錄下的gradle-wrapper.properties檔案檢視
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
或者通過.gradle(通常路徑C:\Users\Administrator.gradle)資料夾下wrapper\dists\gradle-X.XX\9uoz4qrz3xx(亂碼)qtt8z3tsnbtd3e\檢視相應版本
到官網或其他地方自行下載。
2.將下載好的gradle-x.xx.zip放到相應資料夾下(比如.gradle\wrapper\dists\gradle-4.1-milestone-1-all\9uoz4qrz3xxqtt8z3tsnbtd3e\gradle-4.1-milestone-1-all.zip)
3.重啟AS
C盤空間緊張,想把相關的快取目錄更改到其他盤?!
.android
.android存放的是AVD(Android Virtual Devices).
建立一個ANDROID_SDK_HOME環境變數,值為你希望.android資料夾在的位置,剪下.android資料夾到新目錄下,我是刪除AVD後重新建立。(在修改.AndroidStudio路徑後,啟動AVD,出現一個WARNING:
Emulator: I/O warning : failed to load external entity “file:/C:/Users/Administrator/.AndroidStudioPreview3.0/config/options/updates.xml”
不知怎麼解決,誰知道請告知,多謝,AVD是可以啟動的)
.AndroidStudio
修改AndroidStudio安裝目錄下bin下面的idea.properties檔案中的
idea.config.path 和idea.system.path為新目錄,剪下原來的到新目錄下(可能有多個,如.AndroidStudio .AndroidStudio2.3 .AndroidStudio3.0等,找對應版本)
#---------------------------------------------------------------------
# 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:/android_studio/cache/.AndroidStudioPreview3.0/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}/.AndroidStudioPreview/system
idea.system.path=D:/android_studio/cache/.AndroidStudioPreview3.0/system
.gradle
修改Settings/Build,Execution,Deployment/Gradle的Service directory path,如圖
複製舊的.gradle內容到新目錄(由於主要是gradle難下載,所以可以只複製wrapper目錄結構和zip包即可,如.gradle\wrapper\dists\gradle-4.1-milestone-1-all\9uoz4qrz3xxqtt8z3tsnbtd3e\gradle-4.1-milestone-1-all.zip,AS會自行解壓和下載其他依賴)
.m2
修改Settings/Appearance&Behavior/Path Variables的MAVEN_REPOSITORY,如圖