Android Studio 3.1.4 Gradle Sync Failed

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!

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.

Leave a Comment