This question is different from similar questions in that: I only see this error for some Android devices.
Despite setting up application SHA1 in Firebase and Play Console I'm still encountering SIGN_IN_REQUIRED error. I tested on 5 devices and this only happens on 1. Futhermore, it is a persistent issue on this one device, regardless of using Debug, Release, or Play Console signed builds.
Via Crashlytics I recently saw that another user is seeing the same error.
Code:
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
}
Logs:
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)