Android Studio 3.1.4 Gradle Sync Failed

go to address https://github.com/clarketm/proxy-list select one proxy and port

Go to AS Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy -> Manual proxy configuration -> HTTP: Host name: ip - Port: port ->check Proxy Authentication check adress https://developer.android.com/studio/ if ok end


Of course, link is blocked by our (Iranian IPs) so, the idea is to enable VPN then reopening Android Studio and if it couldn't download it again, Invalidate Caches/Restart :

(Android Studio -> File -> Invalidate Caches/Restart)

then you should be good to go.

This also could happen for adding a Library in Gradle.build which can be bypassed by this method.


Finally it worked!

UPDATE (Best Answer)

JCenter detects most VPNs, I have a better solution for you (Iranian developers):

There is a service that helps us to pass restrictions (like JCenter, Android Developer, and so many services): https://shecan.ir (شکن), you can use that fast service without disconnection or other headaches (it uses DNS to bypass restrictions, so usually faster than VPN).

Old Answer

Dear Iranian Developers, you can easily solve this problem with these simple steps:

1 - Turn on the Psiphon

2 - In the Psiphon (VPN) go to Settings -> Local Proxy Ports -> HTTP, HTTPS: 63620 - SOCKS: 63621. This will force the Psiphon to always use port 63620 for HTTP.

3- Go to AS Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy -> Manual proxy configuration -> HTTP: Host name: 127.0.0.1 - Port: 63620 -> Uncheck Proxy Authentication.

Note: These ports (63620, 63621) are custom, but the HTTP port of the Psiphon and the AS HTTP Proxy Settings must be the same.

4 - Note: Android Studio works online only the first time you create the project. After that, you can work offline and build your project or sync it again with Gradle.

Done!


I also faced this issue after updating Android Studio.

I resolved it by downgrading the version of com.android.tools.build:gradle in project level build.gradle file same like old projet.

1> Open your another project

-------Check version of com.android.tools.build:gradle in Project level gradle

-------Check distributionUrl version in gradle-wrapper.properties

2> Apply both these version in your project

Project level build.gradle

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1' // your version

gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip // your version

Sync and run, All errors gone!