问题
I want to use leaderboards in my game. I set up game services project in developer's console, built api client and connected to it. But when I try to retrieve leaderboard with following code (I replaced actual id with my_leaderboard_id):
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient, LEADERBOARD_ID), 100);
I receive following error:
05-18 17:25:04.330: E/Volley(1443): [149] BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/games/v1/leaderboards/my_leaderboard_id?language=ru_RU
05-18 17:25:04.330: E/LeaderboardAgent(1443): Unable to retrieve leaderboard my_leaderboard_id
05-18 17:25:04.330: E/LeaderboardAgent(1443): No instance found for leaderboard my_leaderboard_id for SOCIAL and ALL_TIME
05-18 17:25:04.373: E/AndroidRuntime(13891): java.lang.NullPointerException: Attempt to invoke interface method 'com.google.android.gms.games.Game com.google.android.gms.games.leaderboard.Leaderboard.getGame()' on a null object reference
So, leaderboard cannot be retrieved. But it seems that posting score works fine (at least there are no error messages in LogCat):
Games.Leaderboards.submitScore(mGoogleApiClient, LEADERBOARD_ID, score);
It is also needed to be mentioned, that I haven't published game services project yet, so it is in "Ready to test" state. But my e-mail is in testers list, so I suppose everything should be fine with this. Anyone has a clue what can be wrong here?
回答1:
That was my fault, I used my game services project id instead of leaderboards id by mistake. Now it works.
来源:https://stackoverflow.com/questions/30306096/cant-retrieve-leaderboard