首页 > 解决方案 > 未解决的参考 GoogleSignIn

问题描述

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

当前文件设置:

设置.gradle

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

项目等级:

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

应用等级:

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

最后导入:

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

我尝试重建项目、刷新 Gradle 项目和使缓存无效,但我仍然得到未解决的 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

标签: androidandroid-studioandroid-gradle-plugingoogle-play-services

解决方案


您不应该在您的项目中实现所有 google play 服务以仅使用身份验证服务

Apk文件的大小会增加,所以替换依赖如下

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

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


推荐阅读