Gradle 安装有代理问题

时间:2023-02-01
本文介绍了Gradle 安装有代理问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 Jenkins 代理后面的公司网络中的服务器上构建 android 项目时遇到了问题.已经尝试过 jenkins gradle 和 gradlew.以下是开启调试模式后的错误信息.

17:12:31 17:12:40.482 [INFO] [com.android.build.gradle.internal.DependencyManager] 解析/opt/android/tools/package.xml17:12:32 17:12:42.383 [调试] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck 正在运行17:12:42 17:12:52.384 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] 等待获取守护进程地址注册表的共享锁.17:12:42 17:12:52.384 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] 获取锁.17:12:42 17:12:52.384 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] 释放对守护进程地址注册表的锁定.17:12:46 17:12:55.512 [警告] [com.android.build.gradle.internal.DependencyManager] 无法连接到主机:https://dl.google.com/android/repository/addons_list-3.xml17:12:46 17:12:55.513 [警告] [com.android.build.gradle.internal.DependencyManager] 无法连接到主机:https://dl.google.com/android/repository/addons_list-2.xml17:12:46 17:12:55.514 [警告] [com.android.build.gradle.internal.DependencyManager] 无法连接到主机:https://dl.google.com/android/repository/addons_list-1.xml17:12:46 17:12:55.515 [警告] [com.android.build.gradle.internal.DependencyManager] 无法下载任何源列表!17:12:46 17:12:55.516 [警告] [com.android.build.gradle.internal.DependencyManager] java.net.UnknownHostException: dl.google.com17:12:46 17:12:55.543 [错误] [org.gradle.internal.buildevents.BuildExceptionReporter]17:12:46 17:12:55.544 [错误] [org.gradle.internal.buildevents.BuildExceptionReporter] 失败:构建失败并出现异常.

这是 gradle.properties 的内容.

systemProp.http.proxyHost=proxy.serversystemProp.https.proxyHost=proxy.serversystemProp.http.proxyPort=8080systemProp.https.proxyPort=8080

我尝试使用 jvm 标志传递代理设置,并尝试了 gradle 版本 3.3 到 3.5.有什么我遗漏的吗?

解决方案

对我来说 问题 是 http 前缀!如果是这种情况,请删除 http/https 前缀!

我的 gradle.properties 是这样的,但失败了:

systemProp.http.proxyHost=http://squid.proxy.comsystemProp.http.proxyPort=8080systemProp.https.proxyHost=http://squid.proxy.comsystemProp.https.proxyPort=8080

<小时><块引用>

为 gradle 设置代理设置的正确方法是:

systemProp.http.proxyHost=squid.proxy.comsystemProp.http.proxyPort=8080systemProp.https.proxyHost=squid.proxy.comsystemProp.https.proxyPort=8080

I'm running into issues building android projects on a server in a corporate network behind a proxy on Jenkins. Have tried with both the jenkins gradle, as well as gradlew. Below is the error message after turning on debug mode.

17:12:31 17:12:40.482 [INFO] [com.android.build.gradle.internal.DependencyManager] Parsing /opt/android/tools/package.xml

17:12:32 17:12:42.383 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
17:12:42 17:12:52.384 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
17:12:42 17:12:52.384 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
17:12:42 17:12:52.384 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.

17:12:46 17:12:55.512 [WARN] [com.android.build.gradle.internal.DependencyManager] Failed to connect to host: https://dl.google.com/android/repository/addons_list-3.xml
17:12:46 17:12:55.513 [WARN] [com.android.build.gradle.internal.DependencyManager] Failed to connect to host: https://dl.google.com/android/repository/addons_list-2.xml
17:12:46 17:12:55.514 [WARN] [com.android.build.gradle.internal.DependencyManager] Failed to connect to host: https://dl.google.com/android/repository/addons_list-1.xml
17:12:46 17:12:55.515 [WARN] [com.android.build.gradle.internal.DependencyManager] Failed to download any source lists!
17:12:46 17:12:55.516 [WARN] [com.android.build.gradle.internal.DependencyManager] java.net.UnknownHostException: dl.google.com
17:12:46 17:12:55.543 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
17:12:46 17:12:55.544 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.

This is the contents of gradle.properties.

systemProp.http.proxyHost=proxy.server
systemProp.https.proxyHost=proxy.server
systemProp.http.proxyPort=8080
systemProp.https.proxyPort=8080

I have attempted passing in proxy settings with jvm flags, and tried gradle versions 3.3 to 3.5. Is there anything that I'm missing?

解决方案

For me the issue was the http prefix! If this is your case, remove http/https prefixes!

I had my gradle.properties like this, and was failing:

systemProp.http.proxyHost=http://squid.proxy.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=http://squid.proxy.com
systemProp.https.proxyPort=8080


Proper way to set proxy settings for gradle is:

systemProp.http.proxyHost=squid.proxy.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=squid.proxy.com
systemProp.https.proxyPort=8080

这篇关于Gradle 安装有代理问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:错误无法解析符号 TabLayout 和“设计" 下一篇:当它具有也是 aar 库的依赖项时,如何为 android 库生成 javadoc?

相关文章

最新文章