Android Studio: Gradle sync failed: Could not HEAD '…'. Received status code 502 from server: Bad Gateway [closed]

僤鯓⒐⒋嵵緔 提交于 2019-11-26 17:44:08

jcenter is having issues at the moment, please check http://status.bintray.com/

After updating the Android Studio to 3.1.0 ,

I just had the same problem, i resolved it using

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

to the TopMost buildScript like this in project-level gradle :-

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

For reference take a sample of the project-level gradle:-

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 resolve the issue fast , you can also try adding these - according to Omar's answer :-

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

along with

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

Thanks to everyone for the quick answers!

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

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

Ok, I slove it by:

In your build.gradle project level, add this:

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
}}

Note that I've updated gradle from 3.0 to 3.1.0

Next: add the same previous links to allprojects's repository body:

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 sync again, and it will work.

For me after applying Santanu Sur's answer The error hapenned again but with another library I have check project's gradle 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 everything is good now

Tip:
When you get your project to build correctly the once enable offline-mode so AS don't have to connect to jcenter every gradle refresh.

I've just clicked Disable Gradle 'offline mode' and sync project and Android Studio downloaded all the needed files.

It's a server response error. Keep trying by pressing "Try Again" after some time. It will be ok automatically.

Uninstalling and Download & install from Developer site solved the issue for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!