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 (将#修改为@)