Google登录不适用于发布版本

问题描述 投票:0回答:2

我正在开发一个应用程序,我需要使用Google和Facebook登录验证我的用户,On Debug构建它们都工作得很好,但是当我将它上传到playstore时,它们都停止了工作,所以对于Facebook登录我需要的一切要做的是在Facebook开发者控制台内公开项目。但谷歌登录无法正常工作。

我在API异常块“10:”中得到这个响应代码,我无法解决这个问题,因为我没有得到任何线索,我做错了,即使没有日志,所以我也可以通过找到罪魁祸首。

这是我正在使用的代码

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestEmail()
        .build();

mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
signInButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        signIn();
    }
});


private void signIn() {
    Intent signInIntent = mGoogleSignInClient.getSignInIntent();
    startActivityForResult(signInIntent, RC_SIGN_IN);
}


private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
    try {
        GoogleSignInAccount account = completedTask.getResult(ApiException.class);
        Uri googleUserPicUrl = null;
        googleUserName = account.getDisplayName();
        googleUserEmail = account.getEmail();
        googleUserPicUrl = account.getPhotoUrl();
        googleUserId = account.getId();
        if (googleUserPicUrl != null) {
            googleUserPic = googleUserPicUrl.toString();
        } else {
            googleUserPic = null;
        }
        storeUserData("google");
    } catch (ApiException e) {
        System.out.println("API EXCEPTION GOOGLE : "+e.getMessage());
    }
}
android login google-login
2个回答
0
投票

我面临同样的问题。上传播放后的应用。您将在Play商店控制台中获得一个sha键,然后复制该键并添加到您的应用程序firebase控制台中,然后再次尝试使用google登录。它会正常工作。你不需要在playstore上上传其他版本。


-1
投票

您必须签署您的应用并将签名配置添加到gradle。以here为例,和here

© www.soinside.com 2019 - 2024. All rights reserved.