Gradle build fails because jcenter() cannot be reached
jcenter.bintray.com is down Error: 502 Bad GatewayShort 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.
Fix it fast
1Find out which cause you have
Find every place the build still points at JCenter.
grep -rn "jcenter" --include=*.gradle --include=*.kts .2Match what you see, then jump to its fix
- 1
grep finds jcenter() in settings, the root build file, buildscript or a modulejcenter() is still in a repositories blockFix - 2
After the switch, one group or artifact cannot be resolved from any repositoryOne dependency exists only on JCenterFix - 3
The build uses your own repository URL, and the error comes from it, not from jcenter.bintray.com directlyA company Artifactory still proxies JCenter firstFix
- 1
What does the error look like?
jcenter.bintray.com is down Error: 502 Bad Gatewaythe 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 buildConfirmed by blog.gradle.org
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 debugRuntimeClasspath2Fix
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 buildConfirmed by blog.gradle.org
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 cache3Verify
Build from a clean Gradle cache on a CI machine.
./gradlew buildConfirmed by jfrog.com
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
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile 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 fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile 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