jcenter.bintray.com is down Error: 502 Bad Gateway

AndroidGradleJcenter

Android Problem Overview


When trying to build my project I am getting the following error:

> Could not GET
> 'https://jcenter.bintray.com/androidx/lifecycle/lifecycle-common/maven-metadata.xml';.
> Received status code 502 from server: Bad Gateway

  • In my build.gradle repositories I don't have JCenter, so this error I'm getting is from dependencies that are still pointing to JCenter.
  • Gradle offline mode is not the solution I'm expecting.
  • I know that JCenter is down and that we should all move to Maven Central (I already did)

Is there a workaround?

Android Solutions


Solution 1 - Android

It's a global outage in JCenter. You can monitor status at https://status.gradle.com. It replaces the bintray status page which seems is now fully sunset and returns a 502 error.

UPDATE Jan 13, 06:35 UTC

JCenter is now back online, and systems are fully operational.

UPDATE Jan 20

Gradle Plugin resolution outage postmortem

https://blog.gradle.org/plugins-jcenter

> Following this incident, the Gradle Plugin Portal now uses a JCenter mirror hosted by Gradle instead of JCenter directly. This should shield users from short JCenter outages for libraries that have been cached by the mirror. We saw another short outage of JCenter over the weekend and this did not appear to impact Gradle Plugin Portal users.

Solution 2 - Android

JFrog, the maintainers of JCenter, announced that they are sunsetting JCenter. This means the following for Android developers for their app's dependencies:

  • March 31st 2021 - Libraries in JCenter will no longer be updated.
  • February 1, 2022 - JCenter will be completely shut down.

Add Maven Central to your project:

  1. Open your root build.gradle
  2. Find lines that say jcenter() and replace them with mavenCentral() (Make sure to add mavenCenteral() in both spots where jcenter() is found.)

.

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral() // New line
        // jcenter()
       // NOTE: Keep any other entries you may have had here
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.2"
        //... no changes here
    }
}
allprojects {
    repositories {
        google()
        mavenCentral() // New line
        // jcenter()
       // NOTE: Keep any other entries you may have had here
    }
}

You can find more here: https://blog.gradle.org/jcenter-shutdown

Solution 3 - Android

JCenter mentioned it was no longer going to work for new packages starting March 2021, something like that, but it was going to work indefinitely for read-only purposes. It seems right now it is down, but it should get back up sooner rather than later (crossing fingers).

Reference:

Into the Sunset on May 1st: Bintray, GoCenter, and ChartCenter

Solution 4 - Android

This issue affected my Jenkins patching (due to the script trying to grab job-dsl-core from JCenter), so I ended up replacing jCenter() with gradlePluginPortal() in file build.gradle, and all is working fine now.

Solution 5 - Android

I had the same issue today. Since JCenter is being deprecated, we decided to move away from it now.

The problem I found is that the list of repositories used for Gradle plugins is different from the one you use to compile/run your application. Besides removing it from the repositories for your compile/runtime dependencies, you will also need to force Gradle to not use it for plugins. I added the following to my settings.gradle.kts file:

pluginManagement {
    repositories {
        mavenCentral()
        gradlePluginPortal()
    }
}

See Custom Plugin Repositories.

Solution 6 - Android

I am facing the same issue. Using maven { url 'https://maven.aliyun.com/repository/jcenter' } instead of jcenter in the build.gradle file might resolve the issue, but it's not recommended since it's unofficial.

Solution 7 - Android

There was a fall. You can see the status at https://status.gradle.com/.

If you still need to compile your application (but you had already compiled it before), it may be that you have the packages in cache. Deactivate the Internet connection, disconnect the plug, turn off the device you have, enp3s0, eth0, etc. or if you use Android Studio compiling offline.

If your application uses services from your local or external network, after the compilation reconnect to the Internet and everything will work fine. Now, if you have not compiled it before, or you cleared the cache, that is, it is a new application, I have seen several procedures, but none worked for me, just pray.

Solution 8 - Android

Some third-party libraries uses JCenter as repository, but we can override it easily. To do it you just need to create a file called init.gradle.kts inside /android directory (if it is a React Native project) with the following code:

apply<EnterpriseRepositoryPlugin>()

class EnterpriseRepositoryPlugin : Plugin<Gradle> {
    companion object {
        const val ENTERPRISE_REPOSITORY_URL = "https://repo.gradle.org/gradle/repo"
    }

    override fun apply(gradle: Gradle) {
        gradle.allprojects {
            repositories {

                all {
                    if (this !is MavenArtifactRepository || url.toString().contains("jcenter")) {
                        project.logger.lifecycle("Repository ${(this as? MavenArtifactRepository)?.url ?: name} removed.")
                        remove(this)
                    }
                }

                // add the enterprise repository
                add(maven {
                    name = "STANDARD_ENTERPRISE_REPO"
                    url = uri(ENTERPRISE_REPOSITORY_URL)
                })
            }
        }
    }
}

Then, you just need to clean gradlew and build again using:

./gradlew assembleRelease --init-script init.gradle.kts

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLucasView Question on Stackoverflow
Solution 1 - AndroidMikhail TokarevView Answer on Stackoverflow
Solution 2 - AndroidgrgaView Answer on Stackoverflow
Solution 3 - AndroidJav TView Answer on Stackoverflow
Solution 4 - AndroiddiobrandoView Answer on Stackoverflow
Solution 5 - AndroidCarlosView Answer on Stackoverflow
Solution 6 - AndroidPradipto SenSarmaView Answer on Stackoverflow
Solution 7 - AndroiddbdanView Answer on Stackoverflow
Solution 8 - AndroidMurilo MedeirosView Answer on Stackoverflow