可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I've tried to run AndroidStudio
But It's failing on boot with gradle
error:
Failed to import Gradle project: Connection timed out: connect
I found solution here
But I can't find how to set this properties in Android Studio
.
Setting them in graddle-wrapper.properties
doesn't help.
回答1:
In Android Studio -> Preferences -> Gradle, pass the proxy details as VM options.
Gradle VM Options -Dhttp.proxyHost=www.somehost.org -Dhttp.proxyPort=8080
etc.
*In 0.8.6 Beta Gradle is under File->Settings (Ctrl+Alt+S, on windows)
回答2:
Go to gradle.properties
file (project root directory) and add these options.
systemProp.http.proxyHost=www.somehost.org systemProp.http.proxyPort=8080 systemProp.http.proxyUser=user systemProp.http.proxyPassword=password systemProp.http.nonProxyHosts=localhost systemProp.http.auth.ntlm.domain=domain systemProp.https.proxyHost=www.somehost.org systemProp.https.proxyPort=8080 systemProp.https.proxyUser=user systemProp.https.proxyPassword=password systemProp.https.nonProxyHosts=localhost systemProp.https.auth.ntlm.domain=domain
回答3:
For an NTLM Authentication Proxy:
File -> Settings -> Project Settings -> Gradle -> Global Gradle Settings -> Gradle VM Options
-Dhttp.proxyHost=myProxyAddr -Dhttp.proxyPort=myProxyPort -Dhttp.proxyUser=myUsername -Dhttp.proxyPassword=myPasswd -Dhttp.auth.ntlm.domain=myDomainName
回答4:
Rajesh's suggestion did not work for me. What I did was go to
File -> Settings ->HTTP Proxy(Under IDE Settings) ->Manual proxy configuration
I still left the proxy information in Project Settings under Gradle, like Rajesh suggested. But I'm not entirely sure if it's necessary.
I am using 0.8.6 Beta
回答5:
in gradle.properties file (project root directory)
You must set proxy for http and https
systemProp.http.proxyHost=www.somehost.org systemProp.http.proxyPort=8080 systemProp.http.proxyUser=user systemProp.http.proxyPassword=password systemProp.http.nonProxyHosts=localhost systemProp.http.auth.ntlm.domain=domain systemProp.https.proxyHost=www.somehost.org systemProp.https.proxyPort=8080 systemProp.https.proxyUser=user systemProp.https.proxyPassword=password systemProp.https.nonProxyHosts=localhost systemProp.https.auth.ntlm.domain=domain
if you set proxy from File -> Settings ->HTTP Proxy(Under IDE Settings) it only define http proxy and does not set https proxy
回答6:
For Android Studio 1.4, I had to do the following ...
In the project explorer window, open the "Gradle Scripts" folder.
Edit the gradle.properties file.
Append the following to the bottom, replacing the below values with your own where appropriate ...
systemProp.http.proxyHost=?.?.?.? systemProp.http.proxyPort=8080 # Next line in form DOMAIN/USERNAME for NTLM or just USERNAME for non-NTLM systemProp.http.proxyUser=DOMAIN/USERNAME systemProp.http.proxyPassword=PASSWORD systemProp.http.nonProxyHosts=localhost # Next line is required for NTLM auth only systemProp.http.auth.ntlm.domain=DOMAIN systemProp.https.proxyHost=?.?.?.? systemProp.https.proxyPort=8080 # Next line in form DOMAIN/USERNAME for NTLM or just USERNAME for non-NTLM systemProp.https.proxyUser=DOMAIN/USERNAME systemProp.https.proxyPassword=PASSWORD systemProp.https.nonProxyHosts=localhost # Next line is required for NTLM auth only systemProp.https.auth.ntlm.domain=DOMAIN
Details of what gradle properties you can set are here... https://docs.gradle.org/current/userguide/userguide_single.html#sec%3aaccessing_the_web_via_a_proxy
回答7:
In my case I am behind a proxy with dynamic settings.
I had to download the settings script by picking the script address from internet settings at
Chrome > Settings > Show Advanced Settings > Change proxy Settings > Internet Properties > Connections > LAN Settings > Use automatic configuration script > Address
Opening this URL in a browser downloads a PAC file which I opened in a text editor
- Look for a
PROXY
string, it should contain a hostname and port - Copy values into
gradle.properties
systemProp.https.proxyHost=blabla.domain.com
systemProp.https.proxyPort=8081
- I didn't have to specify a user not password.
回答8:
For the new android studio 1.2 you find the gradle vm args under:
File - Settings - Build, Execution, Deployment - Build Tools - Gradle