如何解决Android 登录 Play 游戏 - 给出“statusCode=SIGN_IN_REQUIRED”
我正在尝试让用户登录 Google Play 游戏服务,以便跟踪他们的分数和成就并开始使用排行榜。
我得到的错误是 Status{statusCode=SIGN_IN_REQUIRED,resolution=null},状态代码为 4。我已经三重检查了 SHA1、包名称等,但无法弄清楚出了什么问题。 Play 游戏界面会闪烁几秒钟,显示“正在连接 Play 游戏”。
我已完成以下操作:
• 在控制台中设置的凭据包括范围“./auth/games”(无敏感范围)。
• 测试人员在控制台上添加了我的 Gmail 地址。
• 使用控制台上的配置页面中显示的应用程序 ID 更新清单:
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
• 我使用了以下依赖项:
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.android.gms:play-services-games:21.0.0'
implementation 'com.google.firebase:firebase-auth:20.0.4'
• 使用以下代码登录:
private void startSignInIntent() {
GoogleSignInClient signInClient = GoogleSignIn.getClient(MainActivity.this,GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent,RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
super.onActivityResult(requestCode,resultCode,data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// The signed in account is stored in the result.
GoogleSignInAccount signedInAccount = result.getSignInAccount();
} else {
String message = result.getStatus().getStatusMessage();
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();
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。