部分Android设备出现Play Games错误码4 SIGN_IN_REQUIRED问题求助
问题:部分Android设备Google游戏登录触发SIGN_IN_REQUIRED错误
仅部分Android设备会触发该错误,已在Firebase和Play Console中配置应用SHA1,但测试5台设备里仍有1台持续出现SIGN_IN_REQUIRED错误,且该问题不受Debug、Release或Play Console签名构建版本影响,近期通过Crashlytics发现另有用户遇到相同问题。
相关代码
private fun explicitSignIn(clientId: String?) { val activity = activity ?: return val authCode = clientId ?: getResourceFromContext(context, "default_web_client_id") Log.i(LOG_PREFIX, "explicitSignIn: authCode: $authCode") val builder = GoogleSignInOptions.Builder( GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN ).requestServerAuthCode(authCode) googleSignInClient = GoogleSignIn.getClient(activity, builder.build()) activity.startActivityForResult(googleSignInClient?.signInIntent, RC_SIGN_IN) Log.i(LOG_PREFIX, "explicitSignIn: started sign in flow") } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean { if (requestCode == RC_SIGN_IN) { if (data == null) { Log.w(LOG_PREFIX, "activity finished with null data") return false } val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data) val signInAccount = result?.signInAccount if (result?.isSuccess == true && signInAccount != null) { Log.i(LOG_PREFIX, "sign in activity success") handleSignInResult() } else { Log.w(LOG_PREFIX, "sign in activity failed: " + result.toString()) Log.i(LOG_PREFIX, "sign in result connection result: " + result?.status?.connectionResult.toString()) Log.i(LOG_PREFIX, "sign in result resolution: " + result?.status?.resolution?.toString()) Log.i(LOG_PREFIX, "sign in result status: " + result?.status?.status?.toString()) Log.i(LOG_PREFIX, "sign in result status code: " + result?.status?.statusCode?.toString()) Log.i(LOG_PREFIX, "sign in result status message: " + result?.status?.statusMessage) Log.i(LOG_PREFIX, "sign in result is canceled: " + result?.status?.isCanceled) Log.i(LOG_PREFIX, "sign in result is interrupted: " + result?.status?.isInterrupted) Log.i(LOG_PREFIX, "sign in result is success: " + result?.status?.isSuccess) finishPendingOperationWithError(ApiException(result?.status ?: Status(0))) } return true } Log.w(LOG_PREFIX, "unknown activity requestCode: $requestCode") return false }
错误日志
I/game_services_firebase( 2576): Trying explicit sign in I/game_services_firebase( 2576): explicitSignIn: authCode: <REDACTED>.apps.googleusercontent.com I/game_services_firebase( 2576): explicitSignIn: started sign in flow W/game_services_firebase( 2576): sign in activity failed: com.google.android.gms.auth.api.signin.GoogleSignInResult@a34b5d1 I/game_services_firebase( 2576): sign in result connection result: null I/game_services_firebase( 2576): sign in result resolution: null I/game_services_firebase( 2576): sign in result status: Status{statusCode=SIGN_IN_REQUIRED, resolution=null} I/game_services_firebase( 2576): sign in result status code: 4 I/game_services_firebase( 2576): sign in result status message: null I/game_services_firebase( 2576): sign in result is canceled: false I/game_services_firebase( 2576): sign in result is interrupted: false I/game_services_firebase( 2576): sign in result is success: false I/game_services_firebase( 2576): sign_in_with_game_service: error I/game_services_firebase( 2576): com.google.android.gms.common.api.ApiException: 4: I/game_services_firebase( 2576): at io.revoltgames.game_services_firebase_auth.GameServicesFirebaseAuthPlugin.onActivityResult(GameServicesFirebaseAuthPlugin.kt:282) I/game_services_firebase( 2576): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:774) I/game_services_firebase( 2576): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:422) I/game_services_firebase( 2576): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:857) I/game_services_firebase( 2576): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:884) I/game_services_firebase( 2576): at android.app.Activity.dispatchActivityResult(Activity.java:8969) I/game_services_firebase( 2576): at android.app.ActivityThread.deliverResults(ActivityThread.java:5561) I/game_services_firebase( 2576): at android.app.ActivityThread.handleSendResult(ActivityThread.java:5607) I/game_services_firebase( 2576): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67) I/game_services_firebase( 2576): at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) I/game_services_firebase( 2576): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) I/game_services_firebase( 2576): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) I/game_services_firebase( 2576): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2468) I/game_services_firebase( 2576): at android.os.Handler.dispatchMessage(Handler.java:106) I/game_services_firebase( 2576): at android.os.Looper.loopOnce(Looper.java:205) I/game_services_firebase( 2576): at android.os.Looper.loop(Looper.java:294) I/game_services_firebase( 2576): at android.app.ActivityThread.main(ActivityThread.java:8248)
可行解决方案
- 检查设备Google Play服务版本:SIGN_IN_REQUIRED错误可能因设备Google Play服务过旧导致,引导用户更新到最新版本,或在代码中添加Play服务版本检查逻辑,提示用户更新。
- 验证客户端ID配置:确认
default_web_client_id是否与Google Cloud Console中对应应用的Web客户端ID一致,尤其是多环境(Debug/Release)下的配置是否正确,避免混用客户端ID。 - 添加账号重试逻辑:当触发SIGN_IN_REQUIRED错误时,尝试调用
GoogleSignInClient.signOut()清除本地缓存,再重新发起登录流程,部分设备因本地账号缓存异常导致该问题。 - 检查设备Google账号状态:引导用户在设备设置中检查Google账号是否正常(未被锁定、同步功能开启),部分设备账号异常会导致登录失败。
- 更新Google Sign-In依赖版本:项目中使用的Google Sign-In SDK版本可能存在兼容性问题,升级到最新稳定版本,修复已知的设备适配bug。
- 添加状态解析处理:在错误回调中,若
result.status.resolution不为null,启动该resolution尝试解决登录问题(比如账号权限请求),当前日志中resolution为null,但部分场景下可以通过此方式修复。
内容的提问来源于stack exchange,提问作者orkun1675
相关产品推荐
相关产品推荐

