119

Android Studio Arctic Fox Canary 8 started to warn that JCenter is at end of life

enter image description here

But I cannot just delete jcenter() declarations since it hosts a lot of android artifacts, it would lead to Could not resolve all artifacts error. What is the right way to solve this warning?

Valeriy Katkov
  • 33,616
  • 20
  • 100
  • 123

5 Answers5

135

There's a documentation section describing the problem: JCenter deprecation and end of service. You can find the link by expanding the inspection description (Ctrl+F1). The documentation states:

JFrog, the company that maintains the JCenter artifact repository used by many Android projects, recently announced the deprecation and upcoming retirement of JCenter. According to the announcement, JCenter will allow downloads of existing artifacts until February 1, 2022.

Developers who publish artifacts on JCenter should start migrating their packages to a new host, such as Maven Central.

In the near future, we will provide additional information about migrating Android projects away from JCenter on this page.

The expanded inspection description (as well as the documentation above) suggests to replace jcenter() by mavenCentral(). Acually JCenter is a superset of Maven Central, but such a replacement won't resolve the problem until all JCenter artifacts your project uses will be moved to Maven Central.

I think the optimal solution would be to wait until the libraries you're using are moved from jcenter() and try to replace it with mavenCentral(). If some artifacts are still missing, take a look at the documentation, may be they are moved into another repository and you should add it to the repositories list as well.

repositories {
    google()

//  jcenter()       // <- removed
    mavenCentral()  // <- added
}

If you're a library author you should migrate to another repo, probably it would be Maven Central. Note that according to the JCenter deprecation announcement new submissions are allowed only until March 31st 2021.

A few related resources:

Valeriy Katkov
  • 33,616
  • 20
  • 100
  • 123
  • This does not work for me. I got many dependencies not found errors by just keeping google and mavenCentral..I have to add jcenter after mavenCentral – Arst Nov 03 '22 at 03:56
54

I think that to adhere to a non-breaking migration, instead of deleting the jcenter(), you can keep both and only changing the order in the script itself. That way, jcenter() will always be a fallback to mavenCentral() while the developers are in the process of migrating their artifacts.

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

Ivan Bila
  • 747
  • 7
  • 9
  • 1
    Will it be possible some months/years later a not updated app used jcenter() will have a sudden crash for all users one day when jcenter() is "ended" or "deprecated"? or old app keeps working? – Raii May 18 '21 at 02:59
  • 8
    Starting February 1, 2022 `jcenter` will [work as a read-only repository indefinitely](https://blog.gradle.org/jcenter-shutdown), meaning developers won't be able to push new updates, your app will work unless you add newer versions of a library that are not available on `jcenter` – Ivan Bila May 19 '21 at 02:10
  • I think this doesn't solve anything, if jcenter doesn't find the version then it will simply continue looking at mavenCentral. – htafoya Jun 15 '21 at 17:34
  • I don't know why but I can't remove it nor change the order. It just don't build at all. – Kimi Chiu Apr 14 '22 at 12:55
5

Do not hurry! Nothing needs to be done until the developers of Android Studio make an adequate automatic solution for this situation

user_MGU
  • 978
  • 11
  • 11
4

Wait. Let JCenter come to end of service. Then, pull out the new repositry. It's fine to ignore warnings totally.

NSV.
  • 65
  • 10
3

Find lines that say jcenter() and add mavenCentral() before each of them (Make sure to add mavenCenteral() in both spots where jcenter() is found.)

Adding Maven Central before JCenter means Maven Central will be used by default, and JCenter will still be used as a fallback.

If you attempt to remove jcenter() completely today from your Android project, you may get the following error.

> 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

The reason for this error is that the Android Core dependency still requires JCenter.

Android Studio 4.1.2 and AGP (Android Gradle Plugin) still require a version of a dependency (trove4j) that is only on JCenter.

This is solved in AGP 4.2.0, but this is still in beta and requires Android Studio 4.2 beta or newer.

P R
  • 105
  • 9