未解决的参考GoogleSignIn

时间:2018-08-24 21:46:42

标签: android android-studio android-gradle google-play-services

我收到有关GoogleSignIn的“未解决参考”

当前文件已设置:

settings.gradle

include ':app', ':signin:app'

项目gradle:

buildscript {

ext{
    kotlin_version = '1.2.60'
    lifecycle_version = '1.1.1'
}

repositories {
    jcenter()
    google()
    mavenCentral()
    maven {
        url 'https://maven.fabric.io/public'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'
    classpath 'com.google.gms:google-services:4.0.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'io.fabric.tools:gradle:1.25.4'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
repositories {
    jcenter()
    google()
    maven {
        url 'https://maven.google.com/'
    }
}
}

app gradle:

dependencies {
...
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
...}

最后导入:

import com.google.android.gms.auth.api.signin.GoogleSignIn

我尝试重建Project,刷新Gradle Project和使缓存无效,但我仍然获得GoogleSignIn的未解决参考。 当我尝试将play-services-gcm: 15.0.1 '更改为play-services-gcm: 16.0.0 '(这是最新的Google帐户登录名)时,我收到错误:“无法解决:com.google.android.gms:play-services-gcm:16.0.0”。 安装存储库和同步项目会出现另一个错误“找不到依赖项com.google.android.gms:play-services-gcm:16.0.0”

Gradle版本4.4 Android插件版本3.1.4

1 个答案:

答案 0 :(得分:2)

您不应在项目中实施仅用于身份验证服务的所有Google Play服务

Apk文件的大小将增加,因此请按以下方式替换依赖项

implementation 'com.google.android.gms:play-services-auth:16.0.0'

建议将google-services插件版本更新为4.0.2