[英]Difference between google() and maven { url 'https://maven.google.com' }
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()
}
}
The google()
repository is a shortcut to Google's maven repository. google()
存储库是Google maven资源库的快捷方式。 It was introduced in Gradle 4.x+. 它是在Gradle 4.x +中引入的。 The actual repository URL used is `" https://dl.google.com/dl/android/maven2/ " as specified here.
使用的实际存储库URL是“ https://dl.google.com/dl/android/maven2/ ”,如此处所指定。 https://maven.google.com actually points to the same repository.
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插件。
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存储库的正确网址为:
https://dl.google.com/dl/android/maven2/index.html or 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. 在这里,您可以检查所有支持的库和最新版本。
When using gradle, you can mention multiple repositories which the build tool (gradle) uses to resolve dependencies mentioned in your project.使用 gradle 时,您可以提及构建工具 (gradle) 用于解决项目中提及的依赖项的多个存储库。
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
In the above scenario, you're mentioning 3 repositories which gradle can use to resolve dependencies—all of which are Maven repositories.在上面的场景中,您提到了 gradle 可以用来解决依赖关系的 3 个存储库——它们都是 Maven 存储库。
1. jcenter() 1.j中心()
2. { url 'https://maven.google.com' } 2. { url 'https://maven.google.com' }
jcenter()
in the gradle file.jcenter()
相同。 3. google() 3.谷歌()
maven()
, this can be used in later versions of gradle onlymaven()
符号,这只能在 gradle 的更高版本中使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.