Difference between google() and maven { url 'h

2019-01-11 09:12发布

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()
    }
}

3条回答
男人必须洒脱
2楼-- · 2019-01-11 09:21

To add them to your build, add maven.google.com to the Maven repositories in your module-level build.gradle file:

repositories {
maven {
    url 'https://maven.google.com'
    // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}}

This google() is only used in new android studio 3.0 and after

查看更多
太酷不给撩
3楼-- · 2019-01-11 09:39

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.

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

查看更多
forever°为你锁心
4楼-- · 2019-01-11 09:41

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/index.html or just https://maven.google.com

Here you can check all the supported libraries and the latest versions.

查看更多
登录 后发表回答