无法获取当前登录播放器(Google Play 服务)的分数,但异常 26502:CLIENT_RECONNECT_RE



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

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
}
}
});

如果您能够显示排行榜/成就界面,但无法请求或提交到排行榜,则您可能没有按照文档中所述在 Google Play 管理中心中创建"关联的应用"oauth2 客户端 ID

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

最新更新