Error: could not find com.google.gms:google-services:4.2.0

AndroidFirebaseAndroid StudioAndroid Gradle-PluginJcenter

Android Problem Overview


today I was trying to update com.google.gms:google-services to 4.2.0 from 4.1.0 as it's the latest version and recommended by firebase. But I get this error:

Could not find com.google.gms:google-services:4.2.0.
Searched in the following locations:
    https://jcenter.bintray.com/com/google/gms/google-services/4.2.0/google-services-4.2.0.pom
    https://jcenter.bintray.com/com/google/gms/google-services/4.2.0/google-services-4.2.0.jar
    https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.2.0/google-services-4.2.0.pom
    https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.2.0/google-services-4.2.0.jar
    https://maven.fabric.io/public/com/google/gms/google-services/4.2.0/google-services-4.2.0.pom
    https://maven.fabric.io/public/com/google/gms/google-services/4.2.0/google-services-4.2.0.jar
Required by:
    project :

And here is my project's build gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'

        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.27.0'
    }
}

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

UPDATE:

As Doug Stevenson said the dependency is now up and running so just use google() in your repositories.

If you have any problems with other google repositories (firebase, exoplayer) you can track the issue progress here.

Android Solutions


Solution 1 - Android

Because google-services:4.2.0 is not available at Central Repository, so it needs to be downloaded from Android Tools Repository. To add this to your project add

maven { url 'https://dl.bintray.com/android/android-tools' }

this to buildscript repositories. For more refer to https://mvnrepository.com/artifact/com.google.gms/google-services/4.2.0

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
        //  Add this to your project 
        maven { url 'https://dl.bintray.com/android/android-tools' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'

        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.27.0'
    }
}

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

Solution 2 - Android

Monday December 10 2018, 1:30PM PST

The Google Play services plugin, the Firebase Performance monitoring plug, exoplayer, and possible other dependencies were found to be missing on jCenter. It's not clear why, but some of the teams are known to be moving their build artifacts to the Google maven repo.

As of right now, the Google Play services plugin has been migrated, and should be available through google() in your buildscript for now.

Solution 3 - Android

Try this, work for me:

buildscript {
    repositories {
        google()
        //jcenter()
        jcenter {url 'https://dl.bintray.com/android/android-tools'}
        jcenter {url 'https://firebase.bintray.com/gradle'}
        mavenCentral ()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
    }
}

allprojects {
    repositories {
        google()
        //jcenter()
        jcenter {url 'https://dl.bintray.com/android/android-tools'}
        jcenter {url 'https://firebase.bintray.com/gradle'}
        mavenCentral ()

    }
}

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

Solution 4 - Android

google-services:4.2.0 is now back on google maven repository, just sync gradle with default config:

allprojects {
    repositories {
        google()
        jcenter()
    }
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMJegorovasView Question on Stackoverflow
Solution 1 - AndroidDeepanshu tyagiView Answer on Stackoverflow
Solution 2 - AndroidDoug StevensonView Answer on Stackoverflow
Solution 3 - AndroidNovian AgungView Answer on Stackoverflow
Solution 4 - AndroidHaniView Answer on Stackoverflow