You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio提示cannot resolve symbol auth错误该如何解决?

解决方案

导致该报错的核心原因是Firebase组件与Google Play服务依赖版本不兼容,同时存在已废弃的依赖项,按以下步骤操作即可解决:

  • 修正依赖版本不匹配问题
    你当前的依赖存在版本不兼容问题,同时play-services-gcm已被官方废弃,可直接使用已引入的firebase-messaging替代。将app级build.gradle的依赖块修改为如下内容,使用Firebase官方BOM包自动管理组件版本,避免手动指定版本出现冲突:
dependencies {
    // 引入Firebase官方BOM统一管理所有Firebase组件版本
    implementation platform('com.google.firebase:firebase-bom:32.7.0')
    implementation 'com.google.firebase:firebase-core'
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'com.google.firebase:firebase-auth'
    // 升级Google Play服务相关依赖到匹配的稳定版本
    implementation 'com.google.android.gms:play-services-auth:20.7.0'
    implementation 'com.google.android.gms:play-services-maps:18.2.0'
    implementation 'com.google.android.libraries.places:places:3.3.0'

    implementation 'org.jetbrains:annotations-java5:15.0'
}
  • 清理缓存并重新同步项目
    点击Android Studio顶部菜单栏 File -> Invalidate Caches...,在弹出窗口勾选Clear file system cache and local history,点击Invalidate and Restart,等待IDE重启后重新同步Gradle文件即可。
  • 检查项目级build.gradle配置
    确认根目录build.gradle文件中的Google服务插件为最新稳定版,参考配置如下:
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2' // 可匹配你当前使用的Android Gradle插件版本
        classpath 'com.google.gms:google-services:4.4.0'
    }
}

内容的提问来源于stack exchange,提问作者user17006689

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 15:54:02