Android Google登录失败com.google.android.gms.common.api.ApiException(12500)

【Android Google登录失败com.google.android.gms.common.api.ApiException(12500)】非淡泊无以明志,非宁静无以致远。这篇文章主要讲述Android Google登录失败com.google.android.gms.common.api.ApiException:12500相关的知识,希望能为你提供帮助。
所以我尝试使用Firebase进行Google登录身份验证,此链接提供:https://firebase.google.com/docs/auth/android/google-signin?hl=en
我遵循了每一步,包括将我的SHA-1 Fingerprint放入firebase项目。我目前正处于调试模式,所以我只有一个SHA-1 Fingerprint
这是我的代码:

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.client_id)) .requestEmail() .build(); mGoogleSignInClient = GoogleSignIn.getClient(this, gso); mAuth = FirebaseAuth.getInstance(); LinearLayout gLog = (LinearLayout) findViewById(R.id.googleLogin); gLog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { signIn(); } }); }private void signIn() { Intent signInIntent = mGoogleSignInClient.getSignInIntent(); startActivityForResult(signInIntent, RC_SIGN_IN); }@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { Task< GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { // Google Sign In was successful, authenticate with Firebase GoogleSignInAccount account = task.getResult(ApiException.class); firebaseAuthWithGoogle(account); } catch (ApiException e) { // Google Sign In failed, update UI appropriately Log.w("Error", "Google sign in failed", e); // ... } } }private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d("Akun", "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener< AuthResult> () { @Override public void onComplete(@NonNull Task< AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d("MsgFirebase", "signInWithCredential:success"); FirebaseUser user = mAuth.getCurrentUser(); Intent i = new Intent(login_activity.this, main_activity.class); i.putExtra("nama", user.getDisplayName()); i.putExtra("email", user.getEmail()); startActivity(i); } else { // If sign in fails, display a message to the user. Log.w("MsgFirebase", "signInWithCredential:failure", task.getException()); }// ... } }); }

这是我得到的错误:
com.google.android.gms.common.api.ApiException: 12500: at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source) at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source) at com.mfs.rumah_duka.login_activity.onActivityResult(login_activity.java:112) at android.app.Activity.dispatchActivityResult(Activity.java:6562) at android.app.ActivityThread.deliverResults(ActivityThread.java:3752) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3799) at android.app.ActivityThread.access$1500(ActivityThread.java:154) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1430) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5555) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:118)

我试图检查SigningIntent中的resultCode是否成功。它变成了我们的不是Activity.RESULT_OK。我在登录窗口中选择帐户后立即收到错误。
我试过的解决方案:
  • 将Firebase Google登录设置中的Web客户端ID更改为我的云控制台中的Oath凭据中的一个
  • 将我的gms服务库更新到最新版本(根据Google Sign In error 12500)
  • 在我的云控制台中为Android创建OAuth
这些都没有给我一个解决方案。我试着阅读文档,了解12500的错误代码是什么意思,但似乎没有具体原因。它说尝试使用另一封电子邮件,它仍然是相同的。
有没有人对此有任何解决方案?
答案尝试将您的Google Play服务更新到最新版本,这可能会解决您的问题。
另一答案在Play商店中部署我的flutter应用程序进行内部测试后,我遇到了这个问题,生产密钥的SHA-1无效(生产密钥文件是新的)。几天后我发现了 - 我需要从Google Play商店添加SHA-1> 发布管理> 应用签名> 应用签名证书 -SHA-1证书指纹与本地密钥的SHA-1不同(此证书是在Google Play商店中可见> 版本管理> 应用签名> 上传证书 -SHA-1证书指纹

    推荐阅读