java - Google 登录错误 12500 SHA1 双重检查 GoogleSignInAccount account =completedTask.getResult(ApiException.class);

标签 java android google-signin

我在选择 Google 帐户后收到此错误。 OnActivityResult 被调用,但在评估结果后抛出此错误。原因不是 SHA1 错误,我使用相同的 key 进行发布和调试。该应用程序不是来自 Google Play。我没有使用 firebase。 Google 登录示例使用相同的 key 。

com.google.android.gms.common.api.ApiException:12500:

堆栈跟踪:

W/System.err: com.google.android.gms.common.api.ApiException: 12500: 
W/System.err:     at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
W/System.err:     at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
W/System.err:     at de.org.limindo.limindo2.fragLogin.onActivityResult(fragLogin.java:412)
W/System.err:     at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:151)
W/System.err:     at de.org.limindo.limindo2.MainActivity.onActivityResult(MainActivity.java:788)
W/System.err:     at android.app.Activity.dispatchActivityResult(Activity.java:5456)
W/System.err:     at android.app.ActivityThread.deliverResults(ActivityThread.java:3549)
W/System.err:     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3596)
W/System.err:     at android.app.ActivityThread.access$1300(ActivityThread.java:151)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:110)
W/System.err:     at android.os.Looper.loop(Looper.java:193)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5299)
W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
W/System.err:     at dalvik.system.NativeStart.main(Native Method)

代码是:

           GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();
        mGoogleSignInClient = GoogleSignIn.getClient(fragLogin.this._main, gso);


mSignInGoogle0.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                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 GoogleSignInClient.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        // The Task returned from this call is always completed, no need to attach
        // a listener.
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        handleSignInResult(task);
    }
}


private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
    try {
        GoogleSignInAccount account = completedTask.getResult(ApiException.class);

        // Signed in successfully, show authenticated UI.
        if (account != null)
        {
            mPasswordView.setVisibility(View.GONE);
            mPasswordView.setVisibility(View.GONE);
        }
        updateUI(account);
    } catch (ApiException e) {
        e.printStackTrace();
        // The ApiException status code indicates the detailed failure reason.
        // Please refer to the GoogleSignInStatusCodes class reference for more information.
        Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
        lib.ShowMessage(getContext(), getString(R.string.googleloginnotsuccessfull) + "\n" + getString(R.string.ErrorCode) + GoogleSignInStatusCodes.getStatusCodeString(e.getStatusCode()) + ":" + e.getStatusCode(), getString(R.string.Error));
        updateUI(null);
    }
}

最佳答案

如果这对任何人有帮助:我就处于这种情况,只是它最初有效,后来停止工作。我终于意识到这是因为我换了笔记本电脑。

关于java - Google 登录错误 12500 SHA1 双重检查 GoogleSignInAccount account =completedTask.getResult(ApiException.class);,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53287131/

相关文章:

java - eclipse spring boot 启动项目给出错误

java - 如何从java中保存数据库值的字符串数组计算一小时前的时间

java - 如何在 Spring Boot 中获取传出 http 调用的指标?

android - 如何在不影响 session 计数的情况下触发 Google Analytics 事件?

android - inputType EditText中的textMultiLine和textImeMultiLine有什么区别?

javascript - platform.js 和 analytics.js 被 AdBlocker 拦截

java - 使用类型变量泛型调用方法

android - 内存不足时测试android killing应用程序

oauth - 如何验证 Google 身份服务的响应

android - 谷歌登录并自行加载到新 Activity 后崩溃