Android Studio 3.1.4 Gradle Sync Failed

15,252

Solution 1

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!

Solution 2

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.

Solution 3

use Hotspot Shield

I faced the same problem because this service is banned in Syria

Solution 4

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

Solution 5

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!

Share:
15,252
HF_
Author by

HF_

Updated on June 04, 2022

Comments

  • HF_
    HF_ about 2 years

    Whenever I create a new project in Android Studio it fails at Gradle Sync and always the same error:

    Connection timed out: connect
    
    org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom'.
    

    A screenshot of the IDE:

    It fails exactly when GET this link: https://jcenter.binary.com/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom, but it can receive other links like dl.google.com and SDK Manager. I was getting this error even on AS 3.1.3 and I haven't ever been able to create an Android Application by Android Studio. It can be done easily by Eclipse ADT, but I wanna use Android Studio because it's the official IDE for Android and Google is supporting Android Studio.

    Any way to solve this boring failure of Gradle? (I already searched one thousand times at Google and Stack overflow)

  • HF_
    HF_ almost 6 years
    I already enabled VPN and HTTP Proxy and it can connect to developer.android.com... My problem is jcenter.
  • HF_
    HF_ almost 6 years
    Android Studio -> File -> Invalidate Caches/Restart. No Changes :(
  • ʍѳђઽ૯ท
    ʍѳђઽ૯ท almost 6 years
    This also happens when a VPN have a problem or don't know, can't get connected to that server. Maybe OpenVPN can help.
  • HF_
    HF_ almost 6 years
    Master, my VPN works perfectly and Android Studio can connect to Servers which is restricted our country.
  • F0r3v3r-A-N00b
    F0r3v3r-A-N00b almost 6 years
    I have tried the Invalidate Caches but with the same error. And I'm not using any proxies as I'm connecting directly to the internet.
  • akshay
    akshay over 3 years
    This should go as a comment.
  • StayCool
    StayCool almost 3 years
    Not working. Also, I am not sure that it's safe to use Iranian dns servers =(