Difference among mavenCentral(), jCenter() and mavenLocal()?
Actually, all 3 are Maven repository. We use these maven repositories to our build by using its URL address or its location in the local file system.
By using URL:
repositories {
maven { url("https://plugins.gradle.org/m2/") }
}
By using local file system:
repositories {
maven { url '../maven-repo' }
}
Gradle has three “aliases” which we can use when we are adding Maven repositories to our build. These aliases are:
- mavenCentral():
The mavenCentral() alias means that dependencies are fetched from the central Maven 2 repository.
repositories {
mavenCentral()
}
The URL used to access this repository is https://repo.maven.apache.org/maven2/. The name of the repository is MavenRepo.
- jcenter():
The jcenter() alias means that dependencies are fetched from the Bintray’s JCenter Maven repository
- mavenLocal():
The mavenLocal() alias means that dependencies are fetched from the local Maven repository.
Resource Link:
Gradle: Dependency Management
Maven RepositoryHandler
Jcenter vs. mavenCentral
jcenter() and mavenCentral() is a repository for the Gradle plugin in Android Studio
Earlier versions of Android Studio used mavenCentral(), and after some time, it switched to jcenter.
This is because jcenter() is superior to mavenCentral() in terms of performance and memory footprint:
- Jcenter is the world's largest Java repository
- Jcenter through the CDN service, using the https protocol, highly
secured, and Android Studio 0.8 version mavenCentral() using the http
protocol - Jcenter is a superset of mavenCentral, including many additional
jars - Jcenter performance is better than mavenCentral
- mavenCentral will automatically download many IDE-related indexes,
and these are used less often which are not required.
Resource Link:
https://www.jianshu.com/p/bce437eeb3d3
Last Update: Into the Sunset on May 1st: Bintray, JCenter, GoCenter, and ChartCenter
Update: 24-02-2021 of Android Developers Page:
Announcement Link: https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
Maven Central Link: https://maven.apache.org/repository/index.html
Work Around:
repositories {
mavenLocal()
// jcenter() // <- remove it
mavenCentral() // <- add it
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://repo.spring.io/plugins-release/" }
}
Android Studio Gradle: Please remove usages of `jcenter()` Maven repository from your build scripts / JCenter is at end of life
For koin, change the group id from org.koin
to io.insert-koin
- the latter is published on maven central.
For chartboost, you can use the following repo:
maven {
url "https://dl.bintray.com/google/mobile-ads-adapters-android/"
}
Also note that there are newer versions such as koin 2.2.2 / 3.0.1 and chartboost 8.2.0.0. Older versions are likely not republished in non-jcenter repos.
mvnrepository is a good service for locating packages.
What is the difference between google() and mavenCentral() in project level gradle file in an android project?
They're different Maven artifact repositories, hosted by different entities, with different purposes.
google()
is Google's official Maven repository, where we host Google first-party libraries. This includes the AndroidX libraries, Jetpack Compose, Firebase, Play Services, Material, etc. You can browse what's hosted there online here.
Maven Central is hosted by Sonatype, and allows anyone to upload their projects' artifacts to it. You can read about how to publish there here and search the repository here.
JCenter deprecation; impact on Gradle and Android
The latest update as mentioned here in JFrog's website is the following:
UPDATE 4/27/2021: 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.
Replacing jcenter() in Android Gradle Repositories
JetBrains copied org.jetbrains.trove4j:trove4j:20160824
to Maven Central, which resolves this error. /p>
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
Related Topics
How to Start a New Android Activity Using Class Name in a String
Urlconnection Getcontentlength() Is Returning a Negative Value
Httpurlconnection.Getresponsecode() Returns -1 on Second Invocation
Tm.Getdeviceid() Is Deprecated
Upgrade SQLite Database from One Version to Another
How to Override Action Bar Back Button in Android
Android Webview Always Returns Null for JavaScript Getelementbyid on Loadurl
Translating Ruby Encryption Code to Java
Builder Pattern in Effective Java
How to Include the Spongy Castle Jar in Android
Cannot Resolve Method Getmap()
How to Transform Currenttimemillis to a Readable Date Format
Noclassdeffounderror on External Library Project for Android
What's the Best Practice to Round a Float to 2 Decimals