解决方法(Kotlin)
修改项目根路径下gradle.properties文件,添加如下内容
systemProp.gradle.download.url=https://mirrors.aliyun.com/gradle/
修改项目根路径下settings.gradle.kts文件中的 pluginManagement 和 dependencyResolutionManagement
修改后部分内容如下
pluginManagement {
repositories {
maven { setUrl("https://maven.aliyun.com/repository/central") }
maven { setUrl("https://maven.aliyun.com/repository/google") }
maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven { setUrl("https://maven.aliyun.com/repository/central") }
maven { setUrl("https://maven.aliyun.com/repository/google") }
maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
google()
mavenCentral()
}
}
修改gradle-wrapper.properties添加如下内容
需要把代码中gradle的版本改为和你原有的地址中的版本相同
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-bin.zip
在C:/Windows/System32/drivers/etc/hosts文件中添加
180.163.150.33 google.com
解决方法(Java)
修改项目根路径下gradle.properties文件,添加如下内容
systemProp.gradle.download.url=https://mirrors.aliyun.com/gradle/
修改项目根路径下settings.gradle文件中的 pluginManagement 和 dependencyResolutionManagement
修改后部分内容如下
pluginManagement {
repositories {
maven { setUrl("https://maven.aliyun.com/repository/central") }
maven { setUrl("https://maven.aliyun.com/repository/google") }
maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven { setUrl("https://maven.aliyun.com/repository/central") }
maven { setUrl("https://maven.aliyun.com/repository/google") }
maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
google()
mavenCentral()
}
}