1

I'm experiencing a really annoying problem which i didn't have in any previous game which used Google Play Games API.

My game is working well, not yet published, but the API is published, and everything is working, from submitting a score to viewing the leaderboard.

Now, i need to explain the issue first.

My API account on the Google dev Console has two Oauth keys, the debug and the realese. When i finished the game and tried to view the leaderboard, i viewed it without any problem, but when tried to submit a score, the leaderboard opens and then close without showing my local/global score, its like a glitch in the leaderboard.

I've fixed this issue by publishing the Game's Service. Now i'm having the same issue but with the released APK, the isseu was fixed in the Debug, and i've tried the same steps with the released APK, nothing work.

Every Google account will have the same issue viewing the leaderboard if a score has been submitted, no issue will occur when the user try to only view the leaderboard.

Both Debug and Release keys are added to the firebase and Oauth in Google Dev API Control, and already added the emails im using as testers.

Long story short: After submitting a score, the leaderboard won't open (the leaderboards menu will show, but when selecting a leaderboard this glitched closing will happen).

No logcat was caught, and my code is as the following:

Connection code / not needed

To view the leaderboards:

private void OpenLeaderboards() {
    if(mGoogleApiClient.isConnected()){
        try {
            UpdateAddictionLeaderboard(ReturnSavedClick());
            startActivityForResult(Games.Leaderboards.getAllLeaderboardsIntent(mGoogleApiClient), REQUEST_LEADERBOARD);
        } catch (SecurityException e){
            mGoogleApiClient.disconnect();
            mGoogleApiClient.connect();
        }
    } else {
        isTried = false;
        mGoogleApiClient.connect();
    }

}

To submit a score:

private void UpdateTopScore(final String LeaderBoard, final String Title, final int mSavedScore, final int mMethod){
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(
            mGoogleApiClient,LeaderBoard,
            LeaderboardVariant.TIME_SPAN_ALL_TIME,
            LeaderboardVariant.COLLECTION_PUBLIC)
            .setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {

                @Override
                public void onResult(@NonNull Leaderboards.LoadPlayerScoreResult arg0) {
                    if(isScoreResultValid(arg0)){
                        long score = arg0.getScore().getRawScore();

                        Bundle bundle = new Bundle();
                        bundle.putLong(FirebaseAnalytics.Param.SCORE, score);
                        bundle.putString(LeaderBoard, Title + " Leaderboard");
                        mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.POST_SCORE, bundle);

                        if(mSavedScore > score){
                            Games.Leaderboards.submitScore(mGoogleApiClient, LeaderBoard, mSavedScore);
                        } else {
                            if(mMethod == 0) {
                                mEditor.putInt(FIRSTSCORE, mSavedScore).apply();
                            } else {
                                mEditor.putInt(SECONDSCORE, mSavedScore).apply();
                            }
                        }
                    } else {
                        Games.Leaderboards.submitScore(mGoogleApiClient, LeaderBoard, mSavedScore);
                    }
                }

            });
}

private boolean isScoreResultValid(final Leaderboards.LoadPlayerScoreResult scoreResult) {

    return scoreResult != null && GamesStatusCodes.STATUS_OK == scoreResult.getStatus().getStatusCode() && scoreResult.getScore() != null;
}
Jaeger
  • 1,646
  • 8
  • 27
  • 59
  • Sounds like a race condition. submitScore() and all the other related calls are asynchronous. If you want to submit the score, then show a leaderboard, you need to start the leaderboard intent from the pendingResult callback. Also, are you checking the result codes of the calls? Are they all success? – Clayton Wilkinson Jan 17 '17 at 21:29
  • Yes they are, i'm doing only one request every minute (i know about the limit), its just after the score being submitted, the leaderboard glitch in an awkward way. Like for example, the leaderboard open, then it disappear, then it shows, then disappears, all of these animations happen in 1 second. I think that its related to permission or something ? im not sure about why. – Jaeger Jan 17 '17 at 22:51
  • Well, it was related to this: http://stackoverflow.com/questions/16580885/google-play-game-services-unable-to-sign-in/16970716#16970716 .. i deleted my project and re-created it ( the Games API's one ) and then it worked. – Jaeger Jan 17 '17 at 23:20

0 Answers0