So I found myself scratching my head as I was trying to update my build.gradle dependencies. The com.android.support:appcompat library version 26.0.2 didnt resolve. After a bit of searching I learned that I had to add Google's maven repository to the list of repositories in my project gradle file. So now both Google's maven repository and jcenter() is listed.
So why is Google now hosting their own maven repository and is there any reason not to use it? Its odd that libraries are hosted both places with different versions.
To set up Google as a Maven remote repository, go to Artifactory UI > Admin tab > Repositories > Remote. Click New in the upper right side of the Remote Repositories menu. Choose Maven as the Package Type and configure the URL, as follows:
Maven local repository is a folder location on your machine. It gets created when you run any maven command for the first time. Maven local repository keeps your project's all dependencies (library jars, plugin jars etc.). When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository.
It is a project build tool that comes under the license of Apache, and there are whole hosts of libraries available in the Maven repository. In a project, getting the right JAR files is a difficult task where there could be conflicts in the versions of the two separate packages.
For example, using below mentioned POM.xml, Maven will download dependency (not available in central repository) from Remote Repositories mentioned in the same pom.xml. When we execute Maven build commands, Maven starts looking for dependency libraries in the following sequence −
There are several repositories in play when building an Android app:
jcenter()
is used for a multitude of open source libraries, including the Android Plugin for Gradle.
google()
(a.k.a., maven.google.com
) is used for the support libraries, Architecture Components, and so on. For the support libraries, you need to use this repository for 26.0.0
and higher.
The Android Repository, installed on your hard drive by the SDK Manager, is for the support libraries prior to the introduction of maven.google.com
.
Many other hosted repositories (jitpack.io
, my CWAC repository, etc.).
Its odd that libraries are hosted both places with different versions.
I don't know if maven.google.com
also supports the library versions from the Android Repository. Otherwise, roughly speaking, maven.google.com
is the new hosted version of what had been the Android Repository, for newer versions of the libraries going forward.
I'm also uncertain if the Google Repository installed by the SDK Manager for the Play Services dependencies is being supplanted by maven.google.com
.
why is Google now hosting their own maven repository
You would have to ask Google. The Android Repository was OK for simple builds but got to be a pain in more complex scenarios (e.g., builds on a headless CI server). Using an ordinary hosted Maven repository should simplify those things.
The template project generated by Android Studio didnt add Google's maven repository
You are using Android Studio 2.3.3 or older. Android Studio 3.0 and higher's templates will add google()
for you.
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