Android 无法获取当前已登录播放器(Google Play Services)的分数,例外情况为26502:需要客户端重新连接

Android 无法获取当前已登录播放器(Google Play Services)的分数,例外情况为26502:需要客户端重新连接,android,Android,我想获得当前玩家的排行榜分数。下面是我正在使用的代码片段 LeaderboardsClient leaderboardsClient = Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this)); leaderboardsClient.loadCurrentPlayerLeaderboardScore(getString(R.string.leaderboard_math_game),

我想获得当前玩家的排行榜分数。下面是我正在使用的代码片段

    LeaderboardsClient leaderboardsClient = Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this));
    leaderboardsClient.loadCurrentPlayerLeaderboardScore(getString(R.string.leaderboard_math_game), LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC)
            .addOnCompleteListener(this, new OnCompleteListener<AnnotatedData<LeaderboardScore>>() {
                @Override
                public void onComplete(@NonNull Task<AnnotatedData<LeaderboardScore>> task) {

                    //this is printing
                    Log.d(TAG, "isComplete");
                    try {
                        //below line is giving exception
                        AnnotatedData<LeaderboardScore> score = task.getResult(ApiException.class);
                        Log.d(TAG, "score: " + score.get().getRawScore());
                    } catch (Exception e) {
                        Log.d(TAG, "exception catched: " + e.getMessage());
                        //exception was:
                        //26502: CLIENT_RECONNECT_REQUIRED
                    }
                }
            });
leadsboardsclient leadsboardsclient=Games.getleadsboardsclient(这个,GoogleSignIn.getLastSignedAccount(这个));
排行榜客户端。LoadCurrentPlayerLeadboardScore(getString(R.string.Leadboard\u math\u game)、LeadboardVariant.TIME\u SPAN\u ALL\u TIME、LeadboardVariant.COLLECTION\u PUBLIC)
.addOnCompleteListener(这是新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
//这是印刷
Log.d(标记为“isComplete”);
试一试{
//下面一行是例外
注释数据得分=task.getResult(ApiException.class);
Log.d(标记“score:+score.get().getRawScore());
}捕获(例外e){
Log.d(标记“捕获异常:”+e.getMessage());
//例外情况是:
//26502:需要重新连接客户端
}
}
});

如果您能够显示排行榜/成就用户界面,但不能请求或提交排行榜,则您可能没有在google play控制台中创建“链接应用”oauth2客户端id,如中所述

警告:请确保记录在此步骤中配置的包名称和签名证书。在应用程序中使用不同的证书或包名称将导致身份验证失败