Jason Leddy
Jason Leddy

Reputation: 111

Google Play Games Leaderboard Closes Automatically

Every time I attempt to access my leaderboards within my app, they close automatically. However, the achievements work flawlessly. I am getting error code 10001 (RESULT_RECONNECT_REQUIRED). From the Google Play website,

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.

However, reconnecting does not work.

Here is a list of solutions I found that did not work for me

The code I'm using to present the leaderboards is:

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

Help would be greatly appreciated!

Update 1:

Tried using this in onActivityResult():

System.out.println(client.getConnectionResult(Games.API));

But it simply outputs this:

ConnectionResult{statusCode=SUCCESS, resolution=null, message=null}

On the Google API website, for my app, it shows me that there are a lot of 4xx errors. From 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.

So from this, I can assume that the issue is client-side. But I don't know what could be wrong. I checked my SHA1, app ID, etc., and the achievements work fine. I also tried updating my build.gradle's dependencies to the latest version of Play Services, but it did not fix anything.

Upvotes: 2

Views: 1177

Answers (2)

Sergii Litvinenko
Sergii Litvinenko

Reputation: 126

Had problems with leaderboards too. This solution helped to solve my problem, thanks, but Games. Leaderboards, submitScoreImmediate is deprecated now.

Alternatively you can use :-

yourLeaderboardsClient.submitScoreImmediate(LEADERBOARD_ID, SCORE); 

Works as well and not deprecated. So if anyone encounter such problem - you can use such variant, hope it will help.

Upvotes: 0

Jason Leddy
Jason Leddy

Reputation: 111

So I finally figured it out... Though I previously tried clearing data from Play Games and Play Services without success, I tried it again, and it works. And I figured out why; originally I used:

Games.Leaderboards.submitScore(client, act.getString(id), SCORE);

to submit leaderboard scores. However, when trying to fix my leaderboards, I was using:

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

And for some reason, this works. I've tried switching back and forth between my original method and the new method multiple times, clearing data between each test. The leaderboards only work with the new solution. I have no idea why, but I'm just glad it works.

Upvotes: 1

Related Questions