每次我尝试在我的应用程序中访问我的排行榜时,它们都会自动关闭。但是,这些成就完美无缺。我收到错误代码 10001 (RESULT_RECONNECT_REQUIRED)。来自 Google Play 网站,
The GoogleApiClient is in an inconsistent state and must reconnect to the service to resolve the issue. Further calls to the service using the current connection are unlikely to succeed.
但是,重新连接不起作用。
这是我发现不对我有用的解决方案列表
- 重新安装应用
- 从 Google Play 游戏和 Google Play 服务中删除数据
- 检查服务设置是否正确
我用来显示排行榜的代码是:
act.startActivityForResult(Games.Leaderboards.getAllLeaderboardsIntent(client), RC_SIGN_IN);
//act.startActivityForResult(Games.Leaderboards.getLeaderboardIntent(client, act.getString(R.string.leaderboard_progression)), RC_SIGN_IN); //Single leaderboard does not work either
帮助将不胜感激!
更新 1:
尝试在 onActivityResult() 中使用它:
System.out.println(client.getConnectionResult(Games.API));
但它只是输出:
ConnectionResult{statusCode=SUCCESS, resolution=null, message=null}
在 Google API 网站上,对于我的应用程序,它显示有很多 4xx 错误。来自 http://www.websitepulse.com/kb/4xx_http_status_codes.html ,
4xx - Client Error
This group of HTTP status codes indicates that the request for the resource contains bad syntax or cannot be filled for some other reason, presumably by fault of the client sending the request. Except when responding to a HEAD request, the server SHOULD include an explanation of the error situation and whether it is a temporary or permanent condition. These status codes are applicable to any request method.
因此,我可以假设问题出在客户端。但我不知道可能出了什么问题。我检查了我的 SHA1、应用程序 ID 等,成就工作正常。我还尝试将我的 build.gradle 的依赖项更新到最新版本的 Play 服务,但它没有解决任何问题。
最佳答案
所以我终于弄明白了...虽然我之前尝试从 Play 游戏和 Play 服务中清除数据但没有成功,但我再次尝试了,并且成功了。我想出了原因;最初我使用:
Games.Leaderboards.submitScore(client, act.getString(id), SCORE);
提交排行榜分数。但是,在尝试修复我的排行榜时,我使用了:
PendingResult r = Games.Leaderboards.submitScoreImmediate(client, act.getString(id), SCORE);
ResultCallback callback = new ResultCallback()
{
@Override
public void onResult(@NonNull Result result)
{
//System.out.println(result.getStatus());
//System.out.println(result.getStatus().getStatusMessage());
//System.out.println(result.getStatus().hasResolution());
}
};
r.setResultCallback(callback);
出于某种原因,这行得通。我试过多次在我的原始方法和新方法之间来回切换,每次测试之间都清除数据。排行榜仅适用于新解决方案。我不知道为什么,但我很高兴它有效。
关于android - Google Play 游戏排行榜自动关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39284039/