Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

android - Gradle can't connect to maven repo through corporate proxy - need to configure through Sencha/Cordova

I'm trying to build a Sencha Touch app for android using Cordova. However, after the gradle build kicks off I get a connection error when trying to connect to the maven repo:

[INF] [shellscript] Running: C:xxxgradlew cdvBuildDebug -b C:xxxapplicationcordovaplatformsandroiduild.gradle -Dorg.gradle.daemon=true
[INF] [shellscript]
[INF] [shellscript] FAILURE: Build failed with an exception.
[INF] [shellscript]
[INF] [shellscript] * What went wrong:
[INF] [shellscript] A problem occurred configuring root project '''android'''.
[INF] [shellscript] > Could not resolve all dependencies for configuration ''':classpath'''.
[INF] [shellscript]    > Could not resolve com.android.tools.build:gradle:1.0.0+.
[INF] [shellscript]      Required by:
[INF] [shellscript]          :android:unspecified
[INF] [shellscript]       > Failed to list versions for com.android.tools.build:gradle.
[INF] [shellscript]          > Unable to load Maven meta-data from https://repo1
.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml.
[INF] [shellscript]             > Could not GET '''https://repo1.maven.org/maven
2/com/android/tools/build/gradle/maven-metadata.xml'''.
[INF] [shellscript]                > Connection to https://repo1.maven.org refused

I would imagine this is related to the corporate proxy I have to connect through in my office - however I'm not sure how to configure Gradle to connect via this proxy since it is being executed by Cordova, which is itself being executed by Sencha Cmd.

Is there a way to configure a proxy with Sencha?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You'll need to configure Gradlew to use a proxy server. This is done by creating a gradle.properties file with the following contents:

systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost  

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=userid
systemProp.https.proxyPassword=password
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost

This is an example taken from Chapter 19.3 of the User Guide. Make sure you include both the HTTP and HTTPS values in your file.

You'll place this gradle.properties file in either of these locations:

  1. In your "cordova/platform/android" folder for your mobile project

OR

  1. In your Gradle home folder. For Windows, this is likely %USERPROFILE%.gradle (Ex: C:Usersusername.gradle).

I would recommend putting it in Gradle home so that other projects pick it up and you don't have to worry about putting it under source control.

You can also find more info in this post.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...