Can't retrieve leaderboard

不羁的心 提交于 2020-01-16 06:31:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!