连接到 Google Play 游戏服务不工作

Connect to Google Play Games Services Not Working

我正在尝试连接到 Google Play 游戏,但出现错误。每次都会出现错误 unsuccessful sign in

在我的build.gradle (Module: app)中我有这个代码:

dependencies {
    implementation 'com.google.firebase:firebase-core:17.2.0'
    implementation 'com.google.android.gms:play-services-games:18.0.1'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
}
apply plugin: 'com.google.gms.google-services'

在清单的末尾,我有:

<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" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>

当我使用 MainActivity.java 登录时,我在 onResume:

中调用了这个方法
private void signInSilently() {
    context = getApplicationContext();
    signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
    .requestIdToken(getString(R.string.oauth_client_id))
    .build();
    GoogleSignInAccount signedInAccount = GoogleSignIn.getLastSignedInAccount(context);
    if (GoogleSignIn.hasPermissions(signedInAccount, signInOptions.getScopeArray())) {
        account = signedInAccount;
    } else {
        client = GoogleSignIn.getClient(this, signInOptions);
        client
            .silentSignIn()
            .addOnCompleteListener(
                    this,
                    new OnCompleteListener<GoogleSignInAccount>() {
                        @Override
                        public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
                            if (task.isSuccessful()) {
                                account = task.getResult();
                            } else {
                                Log.d("George", "onComplete: unsuccessful sign in");
                                //signInLoudly();
                            }
                        }
                        });
    }
}
void signInLoudly(){
    GoogleSignInClient signInClient = GoogleSignIn.getClient(this, signInOptions);
    Intent intent = signInClient.getSignInIntent();
    startActivityForResult(intent, RC_SIGN_IN);
}

如果我取消注释 signInLoudly(); 方法,它只会无限循环。

请指教。任何帮助将不胜感激,如果您需要更多信息,请告诉我。

谢谢

问题是该游戏已经连接到 Google API,因此我在 Google Play Games 中创建了一个新游戏,该游戏有效。我希望这对遇到类似问题的人有所帮助。