Gradle installation having a proxy issue

2019-01-19 19:19发布

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?

1条回答
何必那么认真
2楼-- · 2019-01-19 19:50

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
查看更多
登录 后发表回答