为了账号安全,请及时绑定邮箱和手机立即绑定

收到错误 10 后如何让 Google 登录正常工作?

收到错误 10 后如何让 Google 登录正常工作?

HUH函数 2023-05-17 14:34:42
我试图按照指南在我的应用程序上实施 Google 登录。但是,每次尝试登录时,我都会收到错误 10,我知道这意味着开发人员错误,但我无法弄清楚自己做错了什么。我实现了所有代码,确保我有正确的包并更新了 Android Studio。我尝试了来自 SHA1 哈希的不同客户端 ID,这些哈希来自为我的应用程序生成的多个签名包和 apk。我尝试了 Google 为您提供的用于登录的预生成的。有任何想法吗?谷歌登录的意图GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)                .requestEmail()                .requestIdToken(getString(R.string.server_client_id))                .build();        googleSignInClient = GoogleSignIn.getClient(getActivity(),gso);        Intent signInIntent = googleSignInClient.getSignInIntent();        startActivityForResult(signInIntent, 21);OnActivityResult 函数    @Overridepublic void onActivityResult(int requestCode, int resultCode, Intent data) {    callbackManager.onActivityResult(requestCode, resultCode, data);    super.onActivityResult(requestCode, resultCode, data);    if(requestCode == 21) {        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);      handleSignInResult(task);    }    else if (resultCode == RESULT_CANCELED)    {        Log.d("frag", "intent fired and something went wrong");    }}handleSignInResult 函数    private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {    try {        GoogleSignInAccount account = completedTask.getResult(ApiException.class);        // Signed in successfully, show authenticated UI.        Log.d("frag", "Email of account is " + account.getEmail());    } catch (ApiException e) {        // The ApiException status code indicates the detailed failure reason.        // Please refer to the GoogleSignInStatusCodes class reference for more information.        Log.w("ytsignin", "signInResult:failed code=" + e.getStatusCode());    }}
查看完整描述

1 回答

?
暮色呼如

TA贡献1853条经验 获得超9个赞

在开发人员控制台中检查 SHA-1 代码和包名称。大多数情况下,它是导致错误 10 的原因,即“DEVELOPER_ERROR”。将控制台中的 SHA-1 与运行 signingReport 后从 Android Studio 获得的 SHA-1 进行比较。

//img1.sycdn.imooc.com//6464759f0001287903510353.jpg

查看完整回答
反对 回复 2023-05-17
  • 1 回答
  • 0 关注
  • 237 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信