Why does the Google maven repository exist and when should I use it?

后端 未结 1 1122
日久生厌
日久生厌 2021-02-13 04:16

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

1条回答
  •  悲哀的现实
    2021-02-13 04:52

    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.

    0 讨论(0)
提交回复
热议问题