82

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()
    }
}
Amit Kumar
  • 1,320
  • 2
  • 11
  • 19
  • 5
    maven.google for android studio 2.3 and below versions. google() for android studio 3.0.0 and above. ( it's the same fuctionality) –  Sep 28 '17 at 11:04
  • 1
    See [here](https://stackoverflow.com/a/45854844/1370087) for more details. – Benjamin Sep 28 '17 at 11:16

2 Answers2

102

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

Jayson Chacko
  • 2,298
  • 1
  • 10
  • 16
8

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.

Sergio
  • 2,014
  • 1
  • 18
  • 25