记录一下,自己总是遇到的一个创建新项目时候的Cordova打包 gradle下载不下来问题
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not download gradle-4.0.0.jar (com.android.tools.build:gradle:4.0.0)
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.0/gradle-4.0.0.jar'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.0/gradle-4.0.0.jar'.
> Connect to 127.0.0.1:1081 [/127.0.0.1] failed: Connection refused: connect
尝试过的解决方法:
build.gradle文件中添加
maven {url 'https://maven.aliyun.com/repository/google'}
maven { url 'https://maven.aliyun.com/repository/jcenter'}
maven {url "https://maven.aliyun.com/repository/public"}
修改gradle-wrapper.properties中的gradle版本,与build.gradle文件一致
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
不知道都有没有什么用,但是最终的问题原因在报错的127.0.0.1这一行
> Connect to 127.0.0.1:1081 [/127.0.0.1] failed: Connection refused: connect
要删除掉gradle.properties中的代理
我项目中的gradle.properties没有代理,但是在
C:\Users\Administrator.gradle中发现了gradle的代理
## 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
#Thu Jan 14 11:39:31 CST 2021
systemProp.https.proxyPort=1081
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1081
将最后四行代理注释掉就可以了