使用国内镜像提高下载速度,如下,增加 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. 代理配置
配置完成后,如果出现类似“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'”,请检查如下代理配置。
如果之前配置了代理,请停用代理!!!(包括Android Studio的File->Settings->HTTP Proxy
,项目中的gradle.properties
以及系统的~/.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
网友评论