google play服务

icnyk63a  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(709)

我创建了一个简单的游戏,现在我想添加一个排行榜。我遵循了谷歌的文档,但每次当我想获得排行榜时,我都会遇到这样的错误:

W/GmsClient: IGmsServiceBroker.getService failed
java.lang.IllegalStateException: Must contain at least one of the Games scopes!
    at android.os.Parcel.createException(Parcel.java:1958)
    at android.os.Parcel.readException(Parcel.java:1918)
    at android.os.Parcel.readException(Parcel.java:1868)
    at com.google.android.gms.common.internal.IGmsServiceBroker$Stub$zza.getService(com.google.android.gms:play-services-basement@@17.4.0:14)
    at com.google.android.gms.common.internal.BaseGmsClient.getRemoteService(com.google.android.gms:play-services-basement@@17.4.0:268)
    at com.google.android.gms.common.api.internal.GoogleApiManager$zac.zaa(com.google.android.gms:play-services-base@@17.4.0:22)
    at com.google.android.gms.common.api.internal.GoogleApiManager$zac.zaa(com.google.android.gms:play-services-base@@17.4.0:19)
    at com.google.android.gms.common.api.internal.zacb.zab(com.google.android.gms:play-services-base@@17.4.0:43)
    at com.google.android.gms.common.api.internal.zacb.zaa(com.google.android.gms:play-services-base@@17.4.0:49)
    at com.google.android.gms.common.api.internal.zacc.run(com.google.android.gms:play-services-base@@17.4.0:2)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.os.HandlerThread.run(HandlerThread.java:65)

我之所以登录是因为有了这个我就知道自己的名字了

Log.d("name", String.valueOf(account.getGivenName()));

下面是getleaderboard()的代码:

private void showLeaderboard() {
    String s = getString(R.string.leaderboard_id);
    Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this))
            .getLeaderboardIntent(getString(R.string.leaderboard_id))
            .addOnSuccessListener(new OnSuccessListener<Intent>() {
                @Override
                public void onSuccess(Intent intent) {
                    startActivityForResult(intent, RC_LEADERBOARD_UI);
                }
            });
}

在build.gradle中,我有:

implementation 'com.google.android.gms:play-services-auth:19.0.0'
    implementation "com.google.android.gms:play-services-games:21.0.0"

我已经创建了google控制台上的项目,我已经创建了排行榜,oauth2.0也正确设置了sha1
有什么问题?

mf98qq94

mf98qq941#

在用户登录时,您请求了哪些作用域?你必须像这样使用默认的\u游戏\u登录\u

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build();

相关问题