Android Studio: Gradle failed to sync: couldn't HEAD '...'. Received status code 502 from server: Bad Gateway

After updating the version of Android Studio to the latest version (3.1) and gradle in my project, I get an error message (the link is always different):

12:54 Gradle sync started 12:56 Gradle sync failed: Could not HEAD 'https://jcenter.bintray.com/com/android/tools/analytics-library/shared/26.1.0/shared-26.1.0.jar'. Received status code 502 from server: Bad Gateway Consult IDE log for more details (Help | Show Log) (1m 56s 602ms) 12:56 Gradle sync started 12:57 Gradle sync failed: Could not HEAD 'https://jcenter.bintray.com/org/codehaus/mojo/animal-sniffer-parent/1.14/animal-sniffer-parent-1.14.pom'. Received status code 502 from server: Bad Gateway Consult IDE log for more details (Help | Show Log) (1m 4s 266ms) 12:58 Gradle sync started 12:59 Gradle sync failed: Could not HEAD 'https://jcenter.bintray.com/com/sun/activation/all/1.2.0/all-1.2.0.pom'. Received status code 502 from server: Bad Gateway Consult IDE log for more details (Help | Show Log) (1m 29s 985ms) 13:01 Gradle sync started 13:02 Gradle sync failed: Could not HEAD 'https://jcenter.bintray.com/com/sun/activation/javax.activation/1.2.0/javax.activation-1.2.0.pom'. Received status code 502 from server: Bad Gateway Consult IDE log for more details (Help | Show Log) (4s 976ms) 

Android Studio Version:

 Android Studio 3.1 Build #AI-173.4670197, built on March 22, 2018 JRE: 1.8.0_152-release-1024-b02 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains sro Windows 10 10.0 

I already tried a clean rebuild and gradle upgrade, rebooted Android Studio and PC, but to no avail. Any ideas?

PS: Of course, I have the Internet. In addition, if you open the link in a browser, the file is downloaded.

+63
source share
9 answers

jcenter has problems at the moment, please check http://status.bintray.com/

+50
source

After updating Android Studio to version 3.1.0

I had the same problem, I solved it with

  maven { url "https://maven.google.com" } 

for TopMost buildScript like this at the project level gradle: -

  buildscript { repositories { ..... ... maven { url "https://maven.google.com" } 

For reference, take a sample gradle project level: -

 buildscript { repositories { google() jcenter() maven { url 'https://maven.fabric.io/public' } maven { url 'https://jitpack.io' } mavenCentral() maven { url 'https://maven.fabric.io/public' } maven { url "https://maven.google.com" } } dependencies { classpath 'com.android.tools.build:gradle:3.1.0' classpath 'io.fabric.tools:gradle:1.24.4' } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } 

Note : - One more thing: -

In gradle-wrapper.properties use this: -

  distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 

Instead of 4.1-all.zip .

Edit : - If you want to quickly solve the problem, you can also try adding them - according to Omar's answer: -

  maven { url "http://dl.bintray.com/riteshakya037/maven" } 

together with

  maven { url "https://maven.google.com" } 
+15
source

Thanks everyone for the quick answers!

Looks like temporary network issues on jcenter.bintray.com. I just clicked "Try Again" many times, and in the end everything was updated.

In addition, if you open links in a browser, from time to time you will receive a "Service Error" message. So the problem is not on your side.

+6
source

Ok, I bind it:

At the project level build.gradle add the following:

 buildscript { ... repositories { google() jcenter() maven { url 'https://maven.fabric.io/public' } maven { url 'https://jitpack.io' } mavenCentral() maven { url "https://maven.google.com" } } dependencies { classpath 'com.android.tools.build:gradle:3.1.0' // Updated from 3.0 to 3.1.0 // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }} 

Notice that I updated gradle from 3.0 to 3.1.0

Next: add the same previous links to the allprojects repository:

 allprojects { repositories { google() jcenter() mavenCentral() maven { url 'https://jitpack.io' } maven { url "https://maven.google.com" } maven { url 'https://maven.fabric.io/public' } } 

}

One more thing :

In gradle -wrapper.properties use this:

distributionUrl = https://services.gradle.org/distributions/ gradle -4.4-all.zip

After that, just repeat the synchronization and it will work.

+4
source

For me, after applying the answer of Santanu Sur, the error repeated again, but with a different library I checked the gradle project and I found this line maven { url "http://dl.bintray.com/riteshakya037/maven" } in

 allprojects { repositories { maven { url "http://dl.bintray.com/riteshakya037/maven" } maven { url "https://jitpack.io" } jcenter() google() } } 

I deleted it, and now everything is fine.

+2
source

Tip:
When you create the project correctly, enable offline mode once so that the AS does not have to connect to jcenter with every gradle update.

enter image description here

+2
source

I just clicked Disable Gradle "offline" and the synchronization project , and Android Studio downloaded all the necessary files.

+1
source

This is a server response error. Continue trying by clicking Try Again after a while. It will be okay.

+1
source

Removing and downloading and installing from the developer's site solved the problem for me.

+1
source

Source: https://habr.com/ru/post/1276123/


All Articles