Gradle无法解析com.google.android.gms:play-services-auth:11.6.0

use*_*111 10 android google-api google-login android-gradle-plugin

我试图在我的移动应用程序中使用谷歌登录,但我在遵循谷歌的教程后收到以下错误.

"未能解决:com.google.android.gms:play-services-auth:11.6.0"

我的gradle文件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.1.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

另一个是:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.myapp.myapp"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-auth:11.6.0'
}
Run Code Online (Sandbox Code Playgroud)

那么这里有什么问题以及为什么我不能建立这个项目呢?

小智 32

我遇到了同样的问题,我可以通过添加maven { url "https://maven.google.com" }到项目级build.gradle中的存储库列表来解决它,如下所示.

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
    }
}
Run Code Online (Sandbox Code Playgroud)

此外,请确保apply plugin: 'com.google.gms.google-services'在依赖项之后出现此问题以避免版本问题.