Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle build fails because jcenter() cannot be reached

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

Short answer

JCenter was made read-only, then retired and redirected to Maven Central. A build that still lists jcenter() depends on a service that no longer behaves like a normal repository. Remove jcenter(), add mavenCentral(), and keep JCenter only behind a content filter for the rare artifact that lives nowhere else.

  • Applies to Gradle 8.x, Android Gradle Plugin 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find every place the build still points at JCenter.

    grep -rn "jcenter" --include=*.gradle --include=*.kts .
  2. 2Match what you see, then jump to its fix

    1. 1grep finds jcenter() in settings, the root build file, buildscript or a modulejcenter() is still in a repositories blockFix
    2. 2After the switch, one group or artifact cannot be resolved from any repositoryOne dependency exists only on JCenterFix
    3. 3The build uses your own repository URL, and the error comes from it, not from jcenter.bintray.com directlyA company Artifactory still proxies JCenter firstFix

What does the error look like?

  • jcenter.bintray.com is down Error: 502 Bad Gateway
  • the Gradle build fails when it is unable to resolve a dependency from any repository

Cause 1 of 3

jcenter() is still in a repositories block

1Check

JFrog made JCenter read-only on 31 March 2021 and later retired it, redirecting requests to Maven Central. Android's migration guide tells projects not to include jcenter() at all.

grep -rn "jcenter()" --include=*.gradle --include=*.kts .

2Fix

Replace it with Maven Central, and keep google() for Android libraries.

repositories {
    google()
    mavenCentral()
}

3Verify

Resolve dependencies again and watch for any that were found only on JCenter.

./gradlew build

Confirmed by blog.gradle.org

Did this fix it?

Cause 2 of 3

One dependency exists only on JCenter

1Check

Gradle's own write-up shows the example of org.jetbrains.trove4j, which was available only from JCenter when it was written. JFrog's advice for a version missing from Maven Central is to look for a newer version, ask the package owner, drop the dependency or host a copy yourself.

./gradlew :app:dependencies --configuration debugRuntimeClasspath

2Fix

First look for a newer version of the library that is on Maven Central. If none exists, keep JCenter last and limit it to that group with a content filter.

repositories {
    mavenCentral()
    jcenter {
        content {
            includeGroup("org.jetbrains.trove4j")
        }
    }
}

3Verify

The build resolves, and only that group is requested from JCenter.

./gradlew build

Confirmed by blog.gradle.org

Did this fix it?

Cause 3 of 3

A company Artifactory still proxies JCenter first

1Check

JFrog advises creating a new remote repository for Maven Central, adding it to the virtual repository before JCenter and setting the JCenter remote to offline. It also warns not to clear the cache of a JCenter remote, because some cached files may not exist on Maven Central.

grep -rn "artifactory\|jcenter.bintray" --include=*.gradle --include=*.kts --include=*.properties .

2Fix

Make those changes in Artifactory, with the Maven Central remote ahead of JCenter in the virtual repository.

# In Artifactory (admin UI):
# 1. create a remote repository pointing to Maven Central
# 2. add it to the virtual repository above the JCenter remote
# 3. set the JCenter remote to offline; do not clear its cache

3Verify

Build from a clean Gradle cache on a CI machine.

./gradlew build

Confirmed by jfrog.com

Did this fix it?

How do I stop it coming back?

  • Keep jcenter() out of new projects and templates; Android's guide says not to include it.
  • Use content filters whenever you add a repository for one library.
  • Build from a clean cache in CI now and then, so an old cached artifact cannot hide a missing dependency.
  • Look for the new coordinates when a library was published only on JCenter.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.