Java google() 和 maven { url 'https://maven.google.com' } 之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46467561/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between google() and maven { url 'https://maven.google.com' }
提问by Amit Kumar
Is there any difference between google() and maven { url 'https://maven.google.com' } in build.gradle file and if there is any, what is it?
build.gradle 文件中的google() 和 maven { url ' https://maven.google.com' }之间有什么区别,如果有,那是什么?
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
// OR
google()
}
}
采纳答案by Jayson Chacko
The google()
repository is a shortcut to Google's maven repository. It was introduced in Gradle 4.x+. The actual repository URL used is `"https://dl.google.com/dl/android/maven2/" as specified here.https://maven.google.comactually points to the same repository.
该google()
存储库是 Google 的 maven 存储库的快捷方式。它是在 Gradle 4.x+ 中引入的。使用的实际存储库 URL 是此处指定的`" https://dl.google.com/dl/android/maven2/" 。https://maven.google.com实际上指向同一个存储库。
However, if you are planning to use the google()
shortcut, you need Gradle 4.x+, Android Studio 3.x+ and Gradle plugin for Android 3.x+.
但是,如果您打算使用google()
快捷方式,则需要 Gradle 4.x+、Android Studio 3.x+ 和适用于 Android 3.x+ 的 Gradle 插件。
回答by Sergio
Small correction to the answer above. If you try to go to https://dl.google.com/dl/android/maven2/it gives you a 404. The correct url to google maven repository is:
对上述答案的小修正。如果您尝试访问https://dl.google.com/dl/android/maven2/它会给您一个 404。 google maven 存储库的正确 url 是:
https://dl.google.com/dl/android/maven2/index.htmlor just https://maven.google.com
https://dl.google.com/dl/android/maven2/index.html或只是 https://maven.google.com
Here you can check all the supported libraries and the latest versions.
在这里您可以查看所有支持的库和最新版本。