如何在Android中正确设置Google Play登录?

如何在Android中正确设置Google Play登录?,第1张

概述我在android中开发了一个游戏.我尝试实现GooglePlay登录,但显示错误.我无法调试此错误.我尝试在模拟器以外的其他手机型号中安装该应用程序.码:public void startSignInIntent() { startActivityForResult(mGoogleSignInClient.getSignInIntent( @H_404_1@我在android中开发了一个游戏.我尝试实现GooglePlay登录,但显示错误.我无法调试此错误.我尝试在模拟器以外的其他手机型号中安装该应用程序.

@H_404_1@码:

@H_404_1@

public voID startSignInIntent() {         startActivityForResult(mGoogleSignInClIEnt.getSignInIntent(),RC_SIGN_IN);} @OverrIDe    public voID onActivityResult(int requestCode,int resultCode,Intent intent) {        if (requestCode == RC_SIGN_IN) {            Task<GoogleSignInAccount> task =                    GoogleSignIn.getSignedInAccountFromIntent(intent);            try {                GoogleSignInAccount account = task.getResult(APIException.class);            } catch (APIException APIException) {                String message = APIException.getMessage();                if (message == null || message.isEmpty()) {                    message = getString(R.string.signin_other_error);                }                new AlertDialog.Builder(this)                        .setMessage(message)                        .setNeutralbutton(androID.R.string.ok,null)                        .show();            }        }        super.onActivityResult(requestCode,resultCode,intent);    }
@H_404_1@

@H_404_1@

@H_404_1@编辑

@H_404_1@现在,按照建议的方法 *** 作后,登录对话框将立即关闭,而不会显示任何错误.

最佳答案APIException的消息并没有真正告诉您:

@H_404_1@

String message = APIException.getMessage();
@H_404_1@为了调试此问题,APIException的状态将非常有帮助:

@H_404_1@

int StatusCode = APIException.getStatusCode();
@H_404_1@见documentation;它可能与oAuth2范围有关;但问题是缺少构建GoogleSignInClIEnt的代码(可能与重现错误有关).

@H_404_1@另一个怀疑是丢失或过时的google-services.json.它需要添加用于签名该APK包的密钥的匹配(调试或发布或两者兼有)密钥指纹.即使不使用Firebase,也必须在其中设置项目,以便添加密钥指纹并获取一个配置文件(字符串资源中必须有一些Google_app_ID,而这正是070​​02会从中生成的内容)配置文件).

@H_404_1@状态4表示SIGN_IN_REQUIRED:

@H_404_1@

@H_404_1@The clIEnt attempted to connect to the service but the user is not signed in.

@H_404_1@The clIEnt may choose to continue without using the API.

@H_404_1@身份验证失败会提示Google_app_ID或密钥指纹不匹配.想想一个人不需要许可就可以使用GoogleSignInClIEnt获取当前登录的Google帐户…因此,这很可能意味着该API客户端未登录到Google Play. 总结

以上是内存溢出为你收集整理的如何在Android中正确设置Google Play登录? 全部内容,希望文章能够帮你解决如何在Android中正确设置Google Play登录? 所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1145019.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存