首先说表达一下,真的是太恶心了,网上说的很多的方法都是不靠谱的。
下面我展示我的绝招。
1、在C:\Users\XXX\.gradle的init.gradle文件中添加一行代码:allowInsecureProtocol = true(切记有等于号)
allprojects{
repositories {
def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
}
}
maven {
allowInsecureProtocol = true //就是这一行
url ALIYUN_REPOSITORY_URL
url ALIYUN_JCENTER_URL
}
}
}
2、在项目的根目标下的build.gradle中修改:allowInsecureProtocol true(切记无等于号),此外将http改为https
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven {
allowInsecureProtocol true //就是这一行
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
allowInsecureProtocol true //就是这一行
url 'https://maven.aliyun.com/nexus/content/groups/public/'
}
}
}
然后就是好好的等待问题重新构建
|