Http(s) proxy problem

Hi Gradle Team,

I’m trying to setup an AndroidStudio build setup for jenkins, running on Ubuntu 16.04 behind a company firewall.

both gradlew (v. 3.3) and gradle binary zips (v. 3.3 and 4.1-rc1) all finally fail with this error messages for a minmal project in for traget “clean”:

java.net.UnknownHostException: dl.google.com
Failed to connect to host: https://dl.google.com/android/repository/addons_list-3.xml
Failed to connect to host: https://dl.google.com/android/repository/addons_list-2.xml
Failed to connect to host: https://dl.google.com/android/repository/addons_list-1.xml
Failed to download any source lists!

FAILURE: Build failed with an exception.

I’ve set lots of different sources to tell gradle the https proxy:

for 1st start of gradle these settings in ~/.gradle/gradle.properties are sufficient:

systemProp.https.proxyHost=localhost
systemProp.https.proxyPort=3128

but this does not hold for the “addons_list-*.xml” files above.

in the mean time I’ve send HTTPS_PROXY and https_proxy env variables,
as well as

https.proxyHost=localhost
https.proxyPort=3128

in both gradle.properties and java …/jre/lib/net.properties

I’ve tried both (default)

java -version

openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

and

java -version

java version "1.8.0_141"
Java™ SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot™ 64-Bit Server VM (build 25.141-b15, mixed mode)

without success:-(

how do I have to specity the internet proxy for downloading those “addons_list-*.xml” files ???

thanks,

Harald

update:

running “gradle --offline” showed a new error message

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find target with hash string 'android-17' in: /opt/android-sdk-26

which pointed to some install issue with sdk-26 because

# ./sdkmanager --uninstall   platforms\;android-17
Warning: Unable to find package platforms;android-17
done

so I’ve scratched and reinstalled sdk-26 and now – drum roll – gradle works fine and builds the sample project apk!!

still, without “–offline” I get those warnings

Warning: Failed to connect to host: https://dl.google.com/android/repository/addons_list-3.xml
Warning: Failed to connect to host: https://dl.google.com/android/repository/addons_list-2.xml
Warning: Failed to connect to host: https://dl.google.com/android/repository/addons_list-1.xml
Warning: Failed to download any source lists!
Warning: java.net.UnknownHostException: dl.google.com

which IMHO should not happen for my setup ?!

but never mind – it’s building again… :wink:

I have the same kind of problem with SDK 24 and 25.
sdkmanager can update, but not the gradle plugin behind a proxy.
This is solved with gradle-plugin version 3.0.0-beta1 and later.
What look strange to me is that gradle picks up proxy options:
Picked up _JAVA_OPTIONS: -Dhttp.proxyHost=sample.localnet -Dhttp.proxyPort=80 -Dhttps.proxyHost=sample.localnet -Dhttps.proxyPort=80
Here are the system variables

 GRADLE_OPTS='-Dorg.gradle.daemon=false -Dandroid.builder.sdkDownload=true -Dorg.gradle.jvmargs=-Xmx2048M -Dhttp.proxyHost=sample.localnet -Dhttp.proxyPort=80 -Dhttps.proxyHost=sample.localnet -Dhttps.proxyPort=80'
HTTPS_PROXY=http://sample.localnet:80
HTTP_PROXY=http://sample.localnet:80
_JAVA_OPTIONS='-Dhttp.proxyHost=sample.localnet -Dhttp.proxyPort=80 -Dhttps.proxyHost=sample.localnet -Dhttps.proxyPort=80'
http_proxy=http://sample.localnet:80
https_proxy=http://sample.localnet:80