I created simple game and now I want add a leaderboards. i followed google documentation for it but every time when I want to get leaderboard i get this error:
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)
I am logged in because with this i get my name
Log.d("name", String.valueOf(account.getGivenName()));
here is a code of 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);
}
});
}
in build.gradle i have:
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation "com.google.android.gms:play-services-games:21.0.0"
project on google console I have created, leaderboard i have created and OAuth2.0 too SHA1 is set correctly
what can be a problem?
Which scopes have you requested when signing the user in? You must use DEFAULT_GAMES_SIGN_IN like so
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.