我遇到了在Jenkins代理服务器后面的公司网络中的服务器上构建android项目的问题。尝试过jenkins gradle以及gradlew。下面是打开调试模式后的错误消息。
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.
这是gradle.properties的内容。
systemProp.http.proxyHost=proxy.server
systemProp.https.proxyHost=proxy.server
systemProp.http.proxyPort=8080
systemProp.https.proxyPort=8080
我尝试使用jvm标志传递代理设置,并尝试使用gradle版本3.3到3.5。有什么我想念的吗?
答案 0 :(得分:2)
对我而言,issue是http
前缀!如果是这种情况,请删除http/https
前缀!
我有像这样的gradle.properties,并且失败了:
systemProp.http.proxyHost=http://squid.proxy.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=http://squid.proxy.com
systemProp.https.proxyPort=8080
为gradle设置代理设置的正确方法是:
systemProp.http.proxyHost=squid.proxy.com systemProp.http.proxyPort=8080 systemProp.https.proxyHost=squid.proxy.com systemProp.https.proxyPort=8080
答案 1 :(得分:0)
您必须在gradle.configuration
中添加以下配置。如果您正在使用代理,则需要配置这些代理设置。
来源: (https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy)
并且不要在systemProp.http.proxyHost
中仅添加“ www.host.com”中的“ http.//”或“ https:”
。如果您不需要systemProp.http.proxyUser
或proxypassword
登录代理,也可以将其注释掉。
systemProp.proxySet=true
systemProp.http.keepAlive=true
systemProp.http.proxyHost=www.host.com
systemProp.http.proxyPort=port
systemProp.http.proxyUser=username_ifneeded
systemProp.http.proxyPassword=password_needed
systemProp.http.nonProxyHosts=local.net|some.host.com
systemProp.https.keepAlive=true
systemProp.https.proxyHost=host
systemProp.https.proxyPort=port
systemProp.https.proxyUser=username_ifneeded
systemProp.https.proxyPassword=password_ifneeded
systemProp.https.nonProxyHosts=local.net|some.host.com