首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google :仅在Play商店中的SignIn API异常10

Google :仅在Play商店中的SignIn API异常10
EN

Stack Overflow用户
提问于 2020-02-05 23:12:56
回答 1查看 135关注 0票数 0

首先,我已经尝试过这个解决方案:Patrik's Solution。没起作用!

如果我直接从Android运行,它可以很好地工作,但是当我创建和安装签名的APK时,就会发生异常。会发生什么事?

我的代码:

代码语言:javascript
复制
@Override
protected void onCreate(Bundle savedInstanceState) {
...
  btnGoogleLogin.setOnClickListener(V -> singinGoogle());
...
}
void singinGoogle(){      
        Intent singinIntent = mGoogleSignInClient.getSignInIntent();
        startActivityForResult(singinIntent,GOOGLE_SIGN);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==GOOGLE_SIGN){
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            try{
                GoogleSignInAccount account = task.getResult(ApiException.class);
                if(account!=null) {
                    firebaseAuthWithGoogle(account);
                }

            }catch (ApiException e){

                Toast.makeText(this, "ERROR: "+e.getMessage(), Toast.LENGTH_LONG).show();                
                DialogError de = new DialogError();
                FragmentManager fm = this.getSupportFragmentManager();
                dec.show(fm, "");
            }
        }
    }
    private void firebaseAuthWithGoogle(GoogleSignInAccount account){       
        AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(),null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this,task -> {
                    if(task.isSuccessful()){
                        FirebaseUser user = mAuth.getCurrentUser();                       
                    }else {
                        Toast.makeText(this, "The Login as Failed", Toast.LENGTH_SHORT).show();                      
                    }
                });


    }   
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-06 16:02:09

我发现了这个问题,当我生成签名的应用程序时,play商店为应用程序生成一个新的SHA1和MD5密钥。因此,问题的解决方案只是将Play Store密钥复制到Firebase。

逐步解决方案:

  1. 打开Google控制台上的应用程序。
  2. 转到版本管理->应用程序签名
  3. ,复制您想要的
  4. 键,在Firebase控制台中为您的项目添加新密钥。

注意:您也可以保留Android生成的键,这样应用程序就可以在调试和Google上运行。

希望这能有所帮助!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60085462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档