Error when building for Android behind a proxy


#1

Hi,

DETAILS

Platform: I’m using Ionic 2 beta 35 on windows 10 with Java 1.8.0_102 and Android Studio 2.1.3 is installed.

SITUATION

I’m working on a site with a proxy and when I run ‘ionic build android’ I’m getting the following error:

Exception in thread "main"
java.lang.RuntimeException: java.net.ConnectException: Connection refused: connect

Now, I can see that I need to tell java/gradle to use the proxy. I’ve tried to specify this everywhere I can, but it seems to be ignored or overwritten (e.g. when in the platforms/android/*). I’ve created a gradle.properties file in platforms/android/gradle/ and also tried editing the existing gradle-wrapper properties, but they are ignored or over-written respsectively.

Here are the settings I’m creating in the files:


systemProp.http.proxyHost=152.21.12.12
systemProp.http.proxyPort=3001

I’ve also tried telling java to use these settings directly, by specifying the Dhttp.proxyhost=[host] etc. I’ve tried this in the CLI and also in the gradlew.bat file (but the latter gets overwritten).

QUESTION:

Does anyone know where the correct place to set proxy settings is?

Cheers, I’d appreciate any insight :slight_smile:


#2

@Astravagrant Try creating a gradle.properties file in c:/users/YOUR_USERNAME/.gradle/


#3

OK, thanks, @fishgrind, I’ll give that a shot and report back (prob. next week). Cheers!


#4

@fishgrind Sadly, it didn’t work for me, but it convinced my network team to give me non-proxied access, so I’ve circumvented the problem anyway.

Thanks for the suggestion, though!


#5

I am in the same situation, @Astravagrant Could you fix it?

I do not think my team gives me access the network without proxy access :unamused:


#6

I’m afraid not! I couldn’t find any information on it and didn’t have any suggestions that worked for me. I was allowed non-proxied access in the end, so stopped looking into it. Sorry, but I hope you get it sorted :slight_smile:


#7

Thank you @Astravagrant anyway


#8

this is, it may help :

  • replace : repositories { mavenCentral() } to repositories { maven { url "http://repo1.maven.org/maven2" }}
    in files :

    platforms/android/build.gradle
    platforms/android/CordovaLib/build.gradle
    
  • create C:\Programmes\Android\AndroidStudio\gradle\gradle-2.10\gradle.properties :

    systemProp.http.proxyHost=HOST
    systemProp.http.proxyPort=PORT
    systemProp.http.proxyUser=USERNAME
    systemProp.http.proxyPassword=PASS

    systemProp.https.proxyHost=HOST
    systemProp.https.proxyPort=PORT
    systemProp.https.proxyUser=USERNAME
    systemProp.https.proxyPassword=PASS


#9

We finally solved it with the tool CNTLM http://cntlm.sourceforge.net/

Thank you @ekoz and @Astravagrant


#10

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