【问题标题】:Failed to resolve google auth dependency无法解决谷歌身份验证依赖
【发布时间】:2017-11-09 04:56:57
【问题描述】:

我正在尝试按照https://developers.google.com/identity/sign-in/android/start-integrating 的说明进行操作 为我的应用程序创建一个 Google 登录按钮。但是,当我尝试使用时

compile 'com.google.android.gms:play-services-auth:11.6.2'

我收到错误消息“找不到 com.google.android.gms:play-services-auth:11.6.2”。我遵循了类似问题的建议,并确保我的 SDK 是最新的,但没有运气。

项目构建:

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.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()
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
}

应用构建:

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

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "theproject.theapp"
        minSdkVersion 19
        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.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'

    compile 'com.google.android.gms:play-services-auth:11.6.2'
    compile 'com.google.android.gms:play-services-maps:9.0.0'
    compile 'com.google.maps:google-maps-services:0.1.20'

    compile 'com.lorentzos.swipecards:library:1.0.9'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.makeramen:roundedimageview:2.3.0'

    compile 'com.facebook.android:facebook-login:[4,5)'

    testCompile 'junit:junit:4.12'
}

有什么建议吗?谢谢,

伊恩

【问题讨论】:

  • 尝试从 android sdk manager 更新 google play 服务。
  • @HemantParmar 没有像 compile 'com.google.android.gms:play-services-auth:11.6.2' 这样的依赖关系

标签: android gradle google-authentication


【解决方案1】:

play-services-auth

的最新版本
 compile 'com.google.android.gms:play-services-auth:11.6.0'

只需在您的 Gradle.Build 中更改它,没有像 compile 'com.google.android.gms:play-services-auth:11.6.2' 这样的依赖项

更多信息请阅读

Start Integrating Google Sign-In into Your Android App

【讨论】:

  • 我想知道 11.6.2 是从哪里来的……感谢您的快速回答。
  • 欢迎@ihunter2839 很高兴为您提供帮助
  • 将在剩余 4 分钟延迟后接受答案 :)
  • 11.6.2 目前是最新的,android studio 现在会警告你使用可用的最新版本
【解决方案2】:

为了使用 compile 'com.google.android.gms:play-services-auth:11.6.2' 您应该执行以下步骤。

1) 在你的 build.gradle (module) 中替换:

compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:design:25.3.1' compile 'com.android.support:cardview-v7:25.3.1'

与:

compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:cardview-v7:25.4.0'

2) 在您的 build.gradle(项目)中,您应该替换:

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.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()
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
}

与:

    buildscript {
    repositories {
        jcenter()
        mavenCentral()
        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
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

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

【讨论】:

    【解决方案3】:

    只需将 google() 添加到您的 gradle 存储库列表中,现在可以找到 11.6.2 版本。类似的东西:

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

    【讨论】:

      【解决方案4】:

      试试这个:

      菜单:工具AndroidSdk Manager

      检查:显示包裹详情

      安装Android SDK平台27

      好的。当 Android Studio 询问消息时添加 marven 记录错误,只需点击即可。

      将此行从 25 或 26 更改为 27

      compileSdkVersion 27
      targetSdkVersion 27
      

      现在正在工作。

      【讨论】:

        【解决方案5】:

        只需在您的应用程序 gradle 中将 com.android.support 更新到版本 25.4.0

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-05-04
          • 2018-07-02
          • 2012-09-20
          • 2020-08-15
          • 2018-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多