Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Sync failed while using proxy server

I have installed Android studio and i want to build first app. Unfortunately "Gradle project sync failed" Error: Connection refused: connect.

I know it's because i use proxy server (my company does). I already made changes in Setings->HTTP Proxy-> Auto-detect proxy settings, but I guess, Gradle doesn't look on it. I read I should make write in gradle.properties my proxy server, user and password, but I don't know this parameters, and i don't know how to get them (even if it is available or not).

Can you help me? there are two ways: 1. If you know tell me how to avoid this problem without that parameters. For example like Auto-detect 2. How to get those parameters?

like image 324

People also ask

Why is my gradle sync failing?

Bad internet connection: Since Gradle downloads all the missing versions which are required to run your project, it might fail if you don't have a valid internet connection.

How do you fix you may need to adjust the proxy settings in gradle?

On your android studio goto file -- settings -- Build, Execution, Deployment --Build Tools -- Gradle and choose Use local gradle distribution, in the gradle home locate your gradle folder and click apply. Then click okay. This solved the problem for me.

How do I change the proxy settings in IntelliJ gradle?

Configure proxy settings directly from IntelliJ IDEA. Do the following: Open the Version Control | Subversion | Network page of the IDE settings Ctrl+Alt+S . Click the Edit Network Options button and specify the proxy settings in the Edit Subversion Options Related to Network Layers dialog that opens.


1 Answers

Apparently this code works

systemProp.http.proxyHost=<hostname>
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=
systemProp.http.proxyPassword=
systemProp.http.nonProxyHosts=localhost

or for https

systemProp.https.proxyHost=<hostname>
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=
systemProp.https.proxyPassword=
systemProp.https.nonProxyHosts=localhost

when password isn't set up. It should be in gradle.properties file.

like image 195


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!