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

Android集成Firebase时GoogleSignIn标记为内部无法访问及服务版本问题

搞定Google Sign-In的两个小问题:Internal警告 + Play Services版本不兼容

嘿,我来帮你梳理下遇到的这两个问题,其实都是版本依赖相关的,咱们一个个解决:

第一个问题:"GoogleSignIn is marked as internal..." 的警告提示

这个警告是因为你用的Google Sign-In SDK版本可能比较旧,现在Google已经把旧的SDK标记为内部使用,转而推荐使用Google Identity Services (GIS) 架构的新版SDK了。

解决步骤:

  • 先更新你的依赖:打开app/build.gradle,把旧的play-services-auth依赖换成最新稳定版本(比如20.7.0,你可以随时查官方最新版号):
    implementation 'com.google.android.gms:play-services-auth:20.7.0'
    
    注意:如果之前你的版本低于19.0.0,这个替换尤为重要——从19.x开始SDK已经完全迁移到GIS架构,新版会把GoogleSignIn归为正式可用API,警告自然就消失了。
  • 检查你的初始化代码(其实你现在的写法是对的,更新依赖后警告就会消失):
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();
    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
    

第二个问题:Logcat提示"Google Play services out of date..."

这个问题更直接:你测试设备(手机或模拟器)上的Google Play Services版本,低于应用依赖的版本要求(需要12.2.10,却只有11.9.47)。

解决方法按优先级推荐:

  1. 更新设备上的Play Services:这是最稳妥的做法。如果是真实手机,打开Google Play商店搜索"Google Play Services"点击更新;如果是模拟器,要么通过AVD管理器更新系统镜像,要么直接在模拟器内打开Play商店完成更新。
  2. 临时降低依赖版本:如果你暂时没法更新设备,可以把play-services-auth的版本降到和设备匹配的11.9.4:
    implementation 'com.google.android.gms:play-services-auth:11.9.4'
    
    但这只是权宜之计,旧版本可能存在安全隐患,长期来看还是建议更新设备的Play Services。
  3. 加入版本检查代码:在启动登录流程前先做版本校验,避免崩溃或异常:
    int playServicesStatus = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this);
    if (playServicesStatus != ConnectionResult.SUCCESS) {
        if (GoogleApiAvailability.getInstance().isUserResolvableError(playServicesStatus)) {
            // 弹出对话框引导用户更新
            GoogleApiAvailability.getInstance().getErrorDialog(this, playServicesStatus, 9000).show();
        } else {
            Toast.makeText(this, "你的设备不兼容所需的Google Play Services版本", Toast.LENGTH_SHORT).show();
        }
    }
    

这样处理完,两个问题应该都能顺利解决啦。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 03:34:44