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

馋奶兔 提交于 2019-12-16 19:59:54

问题


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'
}

回答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.




回答2:


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

repositories {
    jcenter()
    google()
}



回答3:


add this in your project level gradle file

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



回答4:


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.

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




回答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".




回答6:


Change your top level dependency gradle setting

// 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.3.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
}



回答7:


From Firebase doc:

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

Bottom position of this line not top (below apply plugin: 'com.android.application').




回答8:


In my case I've turned on gradle offline mode that's why it could not find out cached files for that version play-service or can not resolve. When I turn it on back to online everything is ok now.

Android Studio ->> File ->> Gradle ->> offline ->> uncheck




回答9:


Change your top level dependency gradle setting

Open This File --> build.gradle(Project:*****)

and Past This Codes

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

Or Just Change

classpath 'com.android.tools.build:gradle:2.2.2'

to

 classpath 'com.android.tools.build:gradle:3.0.1'



回答10:


Android studio 3.2 Please follow below steps.

1.Invalidate cache and restart option. File->Invalidate/Restart

  1. delete .gradle folder.

It will sync libs in next launch.




回答11:


In my case I already had the google() repository installed. I was unable to resolve the dependency until I rebooted Android Studio. My guess is it couldn't resolve due to some lingering proxy config from when I had Charles open earlier in the day.




回答12:


You can go to the maven to check the latest version

https://mvnrepository.com/artifact/com.google.android.gms/play-services

and then add maven { URL "https://maven.google.com" } to your root level build.gradle file

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


来源:https://stackoverflow.com/questions/46417939/failed-to-resolve-com-google-android-gms-play-services-auth11-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!