android - 谷歌排行榜 ApiException

标签 android google-play-services google-play-games leaderboard

我的排行榜无法正常工作。我可以显示我的排行榜,但提交分数无法使用以下代码我试图找出问题所在,我得到一个 APiException 留言: 26502:CLIENT_RECONNECT_REQUIRED

mLeaderboardsClient = Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this));
    Task<ScoreSubmissionData> task = mLeaderboardsClient.submitScoreImmediate(getString(R.string.leaderboard_id), (long) 67);
    task.addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            if(e instanceof ApiException) {
                writeText("dialog", "ApiException: " + e.getMessage());
            }else{
                writeText("dialog", "Exception: " + e.getMessage());
            }
            dialog.setVisibility(View.VISIBLE);
        }
    });

解锁成就和谷歌登录一样有效。我在互联网上没有发现这个错误消息,所以也许有人知道问题可能是什么。我尝试了不同的登录方式,但没有任何帮助。我试图解决这个问题几天,所以如果你有线索或只是知道问题可能出在哪里,请写信给我。如果您需要更多代码或答案,请随时提出。

最佳答案

您必须确保您在 google play 控制台中添加的客户端 ID 与 google api 控制台中的客户端 ID 相同。

  • 转到 Google Play 控制台选择游戏并选择链接的应用程序。
  • 在页面底部获取 OAuth2 客户端 ID。
  • 点击左侧菜单中的游戏详情。之后单击链接此游戏链接到名为“链接”的 API 控制台项目
  • 单击新页面上的凭据
  • 选择 OAuth 2.0 客户端 ID
  • 页面右侧的客户端 ID 应与您在步骤 2 中获得的相同。

  • 如果这些 id 不同,请将您的游戏与新应用程序链接。

    关于android - 谷歌排行榜 ApiException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48311503/

    相关文章:

    android - 将位图缩放到 80%

    java - Android:下载的图像未显示在 ListView 中

    java - 外部存储和 HTC One V

    Android:是否可以通过编程方式删除系统管理的通知?

    android - 华为 P40 Google Play 服务对话框

    Android - GoogleApiClient - 未连接 fragment 负载

    android - 如何获得玩家ID并显示图片?

    android - GCM 网络管理器可以在非 Play 设备上运行吗?

    android - Google Play 游戏服务 : invite player dialog lacks search by name

    java - 如何从 GooglePlayGames 邀请启动特定 Activity