问题描述
我想在我的比赛中使用排行榜。我在开发者控制台中设置了游戏服务项目,构建了api客户端并连接到它。但是,当我尝试使用以下代码检索排行榜时(我用my_leaderboard_id替换了实际的id):$ p $ start $ c $ startActivityForResult(Games.Leaderboards.getLeaderboardIntent (mGoogleApiClient,LEADERBOARD_ID),100);
我收到以下错误:
<$ p $ > 05-18 17:25:04.330:E / Volley(1443):[149] BasicNetwork.performRequest:用于https://www.googleapis.com/games/v1/的意外响应代码400排行榜/ my_leaderboard_id?language = ru_RU
05-18 17:25:04.330:E / LeaderboardAgent(1443):无法检索排行榜my_leaderboard_id
05-18 17:25:04.330:E / LeaderboardAgent(1443 ):没有发现leader_my_leaderboard_id的社会和ALL_TIME的实例
05-18 17:25:04.373:E / AndroidRuntime(13891):java.lang.NullPointerException:试图调用接口方法com。 google.android.gms.games.Game com.google.android.gms.games.leaderboard.Leaderboard.getGame()'对空引用
所以,无法检索排行榜。但似乎发布分数工作正常(至少LogCat中没有错误消息):
Games.Leaderboards.submitScore( mGoogleApiClient,LEADERBOARD_ID,score);
还需要提及的是,我还没有发布游戏服务项目,所以它处于准备测试状态。但我的电子邮件在测试人员名单中,所以我认为一切都应该没问题。
任何人都有线索在这里有什么可能是错误的? 这是我的错,我用我的游戏服务项目id而不是排行榜id。现在它可以工作。
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?
That was my fault, I used my game services project id instead of leaderboards id by mistake. Now it works.
这篇关于无法检索排行榜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!