为什么存在 Google maven 存储库,我应该什么时候使用它? [英] Why does the Google maven repository exist and when should I use it?

查看:69
本文介绍了为什么存在 Google maven 存储库,我应该什么时候使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以当我试图更新我的 build.gradle 依赖项时,我发现自己摸不着头脑.com.android.support:appcompat 库版本 26.0.2 没有解决.经过一番搜索,我了解到我必须将 Google 的 maven 存储库添加到我的项目 gradle 文件中的存储库列表中.所以现在谷歌的 maven 存储库和 jcenter() 都被列出了.

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.

那么为什么 Google 现在托管自己的 maven 存储库,有什么理由不使用它呢?奇怪的是,图书馆在两个地方都托管有不同的版本.

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.

推荐答案

在构建 Android 应用程序时有几个存储库在起作用:

There are several repositories in play when building an Android app:

  • jcenter() 用于多种开源库,包括适用于 Gradle 的 Android 插件.

  • jcenter() is used for a multitude of open source libraries, including the Android Plugin for Gradle.

google()(又名,maven.google.com)用于支持库、架构组件等.对于支持库,您需要将此存储库用于 26.0.0 及更高版本.

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.

Android 存储库由 SDK 管理器安装在您的硬盘驱动器上,用于在引入 maven.google.com 之前提供支持库.

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.

许多其他托管存储库(jitpack.io、我的 CWAC 存储库等).

Many other hosted repositories (jitpack.io, my CWAC repository, etc.).

奇怪的是,图书馆在两个地方都托管有不同的版本.

Its odd that libraries are hosted both places with different versions.

我不知道 maven.google.com 是否也支持 Android 存储库中的库版本.否则,粗略地说,maven.google.com 是 Android 存储库的新托管版本,用于未来更新版本的库.

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.

我也不确定 SDK 管理器为 Play 服务依赖项安装的 Google 存储库是否被 maven.google.com 取代.

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.

为什么 Google 现在托管自己的 Maven 存储库

why is Google now hosting their own maven repository

你得问问谷歌.Android Repository 适用于简单的构建,但在更复杂的场景(例如,在无头 CI 服务器上构建)就变得很痛苦.使用普通的托管 Maven 存储库应该可以简化这些事情.

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.

Android Studio生成的模板项目没有添加谷歌的maven仓库

The template project generated by Android Studio didnt add Google's maven repository

您使用的是 Android Studio 2.3.3 或更早版本.Android Studio 3.0 及更高版本的模板将为您添加 google().

You are using Android Studio 2.3.3 or older. Android Studio 3.0 and higher's templates will add google() for you.

这篇关于为什么存在 Google maven 存储库,我应该什么时候使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆