Actually, I am studying on build.gradle
file. In some cases, I got that sometimes they are using mavenCentral()
, jCenter()
and mavenLocal()
in repositories section. Sometimes they also using URL. So some question arises in my mind?
i) Difference among mavenCentral(), jCenter() and mavenLocal()?
ii) Which one should I use most?
iii) Is there any performance related issue?
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.
JCenter is a central repository on JFrog Bintray platform for finding and sharing popular JVM language packages in Maven format, used by Maven, Gradle, Ivy, SBT, and others. JCenter is the most comprehensive source for OSS Maven packages, hosting over 340,000 public packages.
Maven Central is a popular repository hosting open source libraries for consumption by Java projects. To declare the Maven Central repository for your build add this to your script: Example 1. Adding central Maven repository. build.gradle.
JCenter is a central artifact repository, like Maven Central. Software projects use JCenter to distribute their software to other people. JCenter also serves as a mirror for Maven Central, so any dependencies available on Maven Central are also available on JCenter (but not vice versa).
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:
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.
The jcenter() alias means that dependencies are fetched from the Bintray’s JCenter Maven repository
The mavenLocal() alias means that dependencies are fetched from the local Maven repository.
Gradle: Dependency Management
Maven RepositoryHandler
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:
Resource Link: https://www.jianshu.com/p/bce437eeb3d3
Last Update: Into the Sunset on May 1st: Bintray, JCenter, GoCenter, and ChartCenter
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/" } }
As per Android Developer page -
JCenter deprecation and end of service
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With