Home » Android » Android Studio 3.1.4 Gradle Sync Failed

Android Studio 3.1.4 Gradle Sync Failed

Posted by: admin June 15, 2020 Leave a comment

Questions:

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)

How to&Answers:

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!

Answer:

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.

Answer:

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!

Answer:

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

Answer:

I had the same problem and update the gradle version to the last one:

Old

classpath 'com.android.tools.build:gradle:3.1.3'

New

classpath 'com.android.tools.build:gradle:3.1.4'

And it worked correctly.

Answer:

In my case, I need to add the google()

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
    }
}