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

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

问题描述

因此,在尝试更新build.gradle依赖项时,我发现自己挠头. com.android.support:appcompat库版本26.0.2无法解析.经过一番搜索,我了解到必须将Google的maven存储库添加到项目gradle文件中的存储库列表中.因此,现在同时列出了Google的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()用于许多开源库,包括Android Gradle插件.

  • 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.

SDK Manager在您的硬盘驱动器上安装的Android Repository用于引入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 Repository中的库版本.否则,大致来说,maven.google.com是Android Repository的新托管版本,用于以后的库的新版本.

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.

我还不确定maven.google.com是否会取代SDK Manager为Play Services依赖性安装的Google Repository.

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

您将不得不问Google. Android存储库对于简单的构建来说还可以,但在更复杂的情况下(例如在无头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生成的模板项目未添加Google的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天全站免登陆