Replacing jcenter() in Android Gradle Repositories

Per JFrog, they are sunsetting Bintray (which includes JCenter) on May 1st, 2021.

To prep for this, I opened my build.gradle and replaced jcenter() with mavenCentral(). My build.gradle now looks like this (with some parts removed):

buildscript {
    ext.kotlin_version = '1.4.21'

    repositories {
        google()
        // jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.5'
    }
}

allprojects {
    repositories {
        google()
        // jcenter()
        mavenCentral()

        maven {
            url "https://jitpack.io"
        }
    }
}

However, since replacing jcenter() with mavenCentral(), I receive this error:

A problem occurred configuring root project 'Redacted'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find org.jetbrains.trove4j:trove4j:20160824.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
       - https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
     Required by:
         project : > com.android.tools.build:gradle:4.1.2 > com.android.tools.build:builder:4.1.2 > com.android.tools:sdk-common:27.1.2

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

Is there another repository I can add to resolve this, or does com.android.tools:sdk-common need to update to use a different version of org.jetbrains.trove4j:trove4j?

Update: Version 4.1.3 still has the same issue.

Answer

JetBrains copied org.jetbrains.trove4j:trove4j:20160824 to Maven Central, which resolves this error. 🎉

If you use additional dependencies that have not yet migrated to Maven Central, you should reach out directly to them.


Update: “the JCenter repository will keep serving packages…until February 1st 2022.” source

Update: Google is working on a fix for build tools 4.2 and maybe 4.1 as well. source

Update: You could try a dependency resolve rule.


The top-level dependency, com.android.tools.build:gradle, started using a newer version of trove4j in 7.0.0-alpha01. (7.0.0-alpha12 is currently the latest.)

Dependency chain: com.android.tools.build:gradle:7.0.0-alpha01 -> com.android.tools.build:builder:7.0.0-alpha01 -> com.android.tools:sdk-common:27.3.0-alpha01 -> org.jetbrains.intellij.deps:trove4j:1.0.20181211

However, this version is still in alpha and requires Android Studio 4.3+, which isn’t even in Beta yet.

I have filed a bug with Google here: https://issuetracker.google.com/issues/179291081