6

At the project level, the Gradle file of an android project contains google() and mavenCentral() inside the repository block.

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.0"
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I have read a related answer Difference between google() and maven { url 'https://maven.google.com' }, but it doesn't describe about mavenCentral(). That answer is based on google() as a replacement of maven { url 'https://maven.google.com' }. But in my case google() and mavenCentral() both are used alongside.

Rawnak Yazdani
  • 1,333
  • 2
  • 12
  • 23
  • 2
    Does this answer your question? [Difference between google() and maven { url 'https://maven.google.com' }](https://stackoverflow.com/questions/46467561/difference-between-google-and-maven-url-https-maven-google-com) – dominicoder Aug 23 '21 at 03:22
  • No, that doesn't answer my question. That doesn't describe mavenCentral(). mavenCentral() is a new replacement for jCenter(). – Rawnak Yazdani Aug 23 '21 at 03:26
  • How about this: https://stackoverflow.com/questions/50726435/difference-among-mavencentral-jcenter-and-mavenlocal – dominicoder Aug 23 '21 at 04:00
  • But that doesn't say any difference with google(). – Rawnak Yazdani Aug 23 '21 at 04:03

1 Answers1

5

They're different Maven artifact repositories, hosted by different entities, with different purposes.

google() is Google's official Maven repository, where we host Google first-party libraries. This includes the AndroidX libraries, Jetpack Compose, Firebase, Play Services, Material, etc. You can browse what's hosted there online here.

Maven Central is hosted by Sonatype, and allows anyone to upload their projects' artifacts to it. You can read about how to publish there here and search the repository here.

Ryan M
  • 18,333
  • 31
  • 67
  • 74