Android Studio Gradle proxy settings

2019-04-10 23:52发布

问题:

I get an error while compiling project:

Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not resolve de.hdodenhof:circleimageview:1.2.1. Required by: MyApp:app:unspecified Could not GET 'https://jcenter.bintray.com/de/hdodenhof/circleimageview/1.2.1/circleimageview-1.2.1.pom'. Received status code 407 from server: authenticationrequired

I set proxy settings

-Dhttp.proxyHost=proxy.domain.company.com -Dhttp.proxyPort=8090 -Dhttp.proxyUser=atiris -Dhttp.proxyPassword=mysecretpassword

But it didn't helped. Also I set http proxy settings i Android Studio.Any help would be greatly appreciated.

回答1:

If you want to use a proxy for a particular project, go to your project directory and locate “gradle.properties” file. It should be in the same directory as “build.gradle” file. If you don’t see one, create one. Make sure to create “gradle.properties” and not “gradle.properties.txt”.

Add your proxy info-

systemProp.http.proxyHost=some-proxy-host.com

systemProp.http.proxyPort=some-port

systemProp.https.proxyHost=some-proxy-host.com

systemProp.https.proxyPort= some-port

If you have authentication as well, add-

systemProp.http.proxyUser=userid

systemProp.http.proxyPassword=password

systemProp.https.proxyUser=userid

systemProp.https.proxyPassword=password

If you want all projects to have the same proxy setting-

Go to your user home directory. In Win 7, it would be “C:\Users\username”. Locate .gradle directory and drop “gradle.properties” file you created above in .gradle directory.



回答2:

Please check the document. I hope this would help:
https://developer.android.com/tools/studio/studio-config.html#proxy