So I just installed Android Studio again after a long time and it asked me to configure the proxy, so I did. I tested the connection and it worked.
Then it asked me
I caught with same issue and was trying bypass proxies in Mac. Removed proxy from system-level(bashrc) and studio(gradle.properties). had no luck!
Found the studio unable to bypass the proxy, finally found the proxy was cahced in gradle in below file.
~/.gradle/gradle.properties
Essentially to make sure proxy referenes were muted in all gradle.prorties, inlcuding gradle cache.
gradle cache could be find as below(in Android view)
Use gradle.properties
file in this path and check proxy info within:
C:\Users\[Windows-User]\.gradle\gradle.properties
I solve the problem by comment proxy definitions in this file.
Commented lines:
#systemProp.http.proxyHost=127.0.0.1
#systemProp.https.proxyPort=9050
#systemProp.https.proxyHost=127.0.0.1
#systemProp.http.proxyPort=9050
#
used for comment in gradle files
My case might be unique as in I got an android project code and was facing this error when trying to build it. I just removed the proxy
properties in gradle.properties
and it worked fine.
I got the issue when I download the glide project and solved the issue by install jdk 1.8.0_151 and reset the JAVA_HOME, and my old jdk is 1.8.0_131, I removed the old version.Hope this can help.
If you ever used ShadowsocksX-NG on Mac, (mine is Version 1.7.1 (1)) and once use the Global Mode, it will automatically add the following command: ~/.gradle/gradle.propertries:
#Mon Nov 18 03:59:09 CST 2019
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyPort=1086
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1086
When you close the ShadowsocksX-NG, the Android studio still use the proxy, that is why it shows
Gradle sync failed: Connection refused
Plz comment those line out, and rebuild the project again.
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Nov 18 03:59:09 CST 2019
#systemProp.http.proxyHost=127.0.0.1
#systemProp.https.proxyPort=1086
#systemProp.https.proxyHost=127.0.0.1
#systemProp.http.proxyPort=1086
On your Mac open your terminal window and hit below command
echo $proxy
It should return your IP address and port number
Now check your gradle.properties of your project and seyt below properties as per your login details
systemProp.http.proxyPort=80
systemProp.http.proxyUser=<userName>
org.gradle.parallel=true
systemProp.http.proxyPassword=<PassWord>
org.gradle.jvmargs=-Xmx1536m
systemProp.https.proxyHost=<IP Address>
systemProp.http.proxyHost=<Proxy Host URL>
systemProp.https.proxyPort=<Port number form above>