这个报错一般是连接不到目标服务器,加载不到依赖会出现,解决思路有以下两种
情况 一、配置了代理,代理没有生效导致的
- 解决方案:可以手动去以下目录
.gradle
目录下找gradle.properties
将代理注释掉,或者删除掉该文件即可
C:\Users\ITPlus\.gradle\gradle.properties
注释掉代理,前面加#
号即可
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Oct 26 17:59:58 CST 2020
#注释掉以下代理
#systemProp.http.proxyHost=huawei.com
#systemProp.http.proxyPort=80
#systemProp.https.proxyHost=huawei.com
#systemProp.https.proxyPort=80
情况二、镜像源访问不到导致的
- 解决方案:建议用阿里开源镜像即可,项目根配置gradle如下:
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/google' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/google' }
}
}