Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 {
    repositories {
        google()
        // jcenter()
        mavenCentral()
    }

    dependencies {
        // ...
    }
}

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.

like image 430
Westy92 Avatar asked Feb 04 '21 15:02

Westy92


People also ask

What can I replace JCenter with?

Jcenter() being replaced in mavenCentral() for gradle - by May 1, 2021.

How do I change JCenter to mavenCentral?

To do so, you must simply add mavenCentral() in your build. gradle file. Make sure to put mavenCentral() before JCenter so that the build script takes the up-to-date versions on mavenCentral in priority.

Is JCenter removed?

Breaking down JFrog's announcement, 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.

Why is gradle using JCenter?

The Gradle Build Init plugin produces build templates that use the JCenter repository to resolve dependencies. In many code examples and documentation, JCenter is used as an example repository. It's very likely that you have builds that rely on JCenter.


1 Answers

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: "We listened to the community and will keep JCenter as a read-only repository indefinitely. Our customers and the community can continue to rely on JCenter as a reliable mirror for Java packages." 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

like image 176
Westy92 Avatar answered Oct 14 '22 03:10

Westy92