Failed to resolve com.google.android.gms play-services-auth:11.4.0

102,598

Solution 1

Failed to resolve com.google.android.gms play-services-auth:11.4.0 .

Add maven { url "https://maven.google.com" } to your root level build.gradle file

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

This maven repo is required starting from 11.2.0.

You can also use the google() shortcut but check the requirements before using it.

Also pay attention since you are using different version. Use the same version.

compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.google.android.gms:play-services-auth:11.4.0'

UPDATE

Firebase Android SDKs and Google Play Services libraries now have independent version numbers, allowing for more frequent, flexible updates. Update the google play service gradle plugin version to latest version (at least 3.3.1).

classpath 'com.google.gms:google-services:4.0.1'

and update the libraries to the latest version.

Solution 2

Add google() repository to your "build.gradle" file. This gradle method is equivalent to maven { url "https://maven.google.com" }.

repositories {
    jcenter()
    google()
}

Solution 3

This error means that google play services 11.4.0 is not installed in your android studio.
To fix this you need to change the version of the dependency to what is installed in your android studio.
For this go to : Project Structure -> Project Settings -> Modules -> Dependencies
Here click on the + sign. Find your desired dependency.You can check its version here.You can also add the dependency to your project from here.

See here

It is always recommended that you update your google play services SDK tools from SDK manager and use the newest version.

Solution 4

add this in your project level gradle file

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

Solution 5

I faced the same problem here today and just had to disable gradle offline work option on "File >> Settings >> Build, Execution, Deployment >> Gradle >> Offline work".

Share:
102,598
Johon smuthio
Author by

Johon smuthio

Hi, I am a software engineer by profession. I have more than 3 years of experience. I have mostly worked with Java and programming. I have worked a lot with java, android, IoT, Azure, AWS, WCNP. Currently, I am working with Walmart as a software engineer.

Updated on November 25, 2021

Comments

  • Johon smuthio
    Johon smuthio over 2 years

    I am trying to write code for Android FirebaseUI — Auth in my android project but from last two days, I am getting errors in my current code and don't know how to fix it. trying hard but nothing happened in the right way.

    here is my build.gradle(project:FriendlyChat)

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
            mavenLocal()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.2'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
            classpath 'com.google.gms:google-services:3.0.0'
        }
    }
    
    allprojects {
        repositories {
            jcenter()
            mavenLocal()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    here is my build.gradle(Module:app)

    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'
    
    repositories {
        mavenLocal()
        flatDir {
            dirs 'libs'
        }
    }
    
    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.1"
    
        defaultConfig {
            applicationId "com.google.firebase.udacity.friendlychat"
            minSdkVersion 16
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE-FIREBASE.txt'
            exclude 'META-INF/NOTICE'
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
    
        // Displaying images
        compile 'com.android.support:design:24.2.1'
        compile 'com.android.support:appcompat-v7:24.2.1'
        compile 'com.github.bumptech.glide:glide:3.6.1'
        compile 'com.google.firebase:firebase-database:11.0.4'
        compile 'com.google.firebase:firebase-auth:11.0.4'
       compile 'com.google.android.gms:play-services-auth:11.4.0'
    
        testCompile 'junit:junit:4.12'
    }
    
  • josemigallas
    josemigallas over 6 years
    Might be worth adding that in my case I had to add this under both allprojects.repositories and buildscript.repositories in build.gradle.
  • Gabriele Mariotti
    Gabriele Mariotti over 6 years
    @josemigallas It is not totally exact. You shoud add it in the buildscript block if you have some dependencies in this repo (for example the new android plugin) otherwise it is not useful to add all repos. In any case it is not related to the question and the 11.4.0
  • Gene Bo
    Gene Bo over 6 years
    In my case I already had mavenCentral() in the repositories section. I wasn't sure if I should keep that and add the one listed in this post. After running it first with the 2 entries for maven - the build failed. I see the existing one I had, should be replaced with the answer here. Very cool - build is happy now
  • Julio Cesar
    Julio Cesar over 6 years
    This answer it is ok for me
  • P Kuijpers
    P Kuijpers almost 6 years
    Since a few weeks it's not all the same versions anymore. Cannot find the blog post about it anymore, but here's the release notes with latest versions: firebase.google.com/support/release-notes/android. Additionally, it should be possible to replace the maven repository definition with a simple google() repository (like naXa mentioned in another answer), but please check my comment on that answer as well.
  • P Kuijpers
    P Kuijpers almost 6 years
    Better! However, even though the newer google() repository definition worked perfectly for my projectlast week, today I cannot build my app anymore unless I add the maven definition instead of google()... Not sure if this is a bug from google or me not understanding the difference? The error says "Could not resolve com.google.android.gms:play-services-measurement-base:[15.0.‌​4]. Required by [...] firebase-analytics:16.0.0"
  • naXa stands with Ukraine
    naXa stands with Ukraine almost 6 years
    @PKuijpers try to ask a new question if you're seeking for help
  • Gabriele Mariotti
    Gabriele Mariotti almost 6 years
    @PKuijpers Yes you are right. Now something changed. I updated the answer.
  • Panduka DeSilva
    Panduka DeSilva over 5 years
    This fixed my issue.