使用國內(nèi)鏡像提高下載速度,如下险耀,增加 aliyun鏡像(buildscript及allprojects都要添加)
1. 根目錄下 build.gradle
buildscript {
repositories {
maven {
url "https://maven.aliyun.com/repository/google"
}
maven {
url "https://maven.aliyun.com/repository/public"
}
maven {
url "https://maven.aliyun.com/repository/jcenter"
}
}
}
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.9.0' apply false
}
2. 根目錄下 settings.gradle(舊版本在build.gradle中allprojects)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven {
url "https://maven.aliyun.com/repository/google"
}
maven {
url "https://maven.aliyun.com/repository/public"
}
maven {
url "https://maven.aliyun.com/repository/jcenter"
}
google()
mavenCentral()
}
}
3. 代理配置
配置完成后,如果出現(xiàn)類似“Could not HEAD 'https://maven.aliyun.com/repository/xxxx.jar'. Received status code 503”、“Could not get resource 'https://maven.aliyun.com/repository/google/xxx.jar'”,請檢查如下代理配置洒闸。
如果之前配置了代理,請停用代理>俊G牦啊!(包括Android Studio的File->Settings->HTTP Proxy
骡技,項目中的gradle.properties
以及系統(tǒng)的~/.gradle/gradle.properties
)
項目中存在兩個gradle.properties
,都要查看確認注釋掉代理配置羞反,如下兩個文件(切換項目目錄到Android模式)布朦。
備注: Global Properites 存在于 jdk目錄下的gradle.properties
參考:
https://blog.csdn.net/myf_666/article/details/128269877
https://blog.csdn.net/triste_who/article/details/90301665