google() 和 maven { url 'https://maven.google.com' } 之间的区别

google() 和 maven { url 'https://maven.google.com' } 之间的区别

问题描述:

google() 和 maven { url 'https://maven.google.com 之间有什么区别吗?' } 在 build.gradle 文件中,如果有的话,是什么?

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?

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        // OR
        google()
    }
}

google() 存储库是 Google 的 maven 存储库的快捷方式.它是在 Gradle 4.x+ 中引入的.使用的实际存储库 URL 是 `"https://dl.google.com/dl/android/maven2/" 指定 此处. https://maven.google.com 实际上指向同一个存储库.

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.com actually points to the same repository.

但是,如果您打算使用 google() 快捷方式,则需要 Gradle 4.x+、Android Studio 3.x+ 和适用于 Android 3.x+ 的 Gradle 插件.

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