I'm updating my game to the new Google Play Serviced library, leaderboards and achievements were already working flawlessly, but now when I try to open the achievement activity, it immediately closes without showing any exception in logcat. I'm logged in with my google account, which is correctly configured as a test user.
public void gameServicesGetAchievements() {
if (gameHelper == null)
return;
Intent i = Games.Achievements.getAchievementsIntent(gameHelper.getApiClient());
((Activity) ctx).startActivityForResult(i, REQUEST_CODE_ACHIEVEMENTS);
}
The activity opens, but closes immediately before showing the achievements list. This is what I get in logcat
D/GameHelper(30459): GameHelper: onActivityResult: req=9802, resp=RESULT_RECONNECT_REQUIRED
D/GameHelper(30459): GameHelper: onActivityResult: request code not meant for us. Ignoring.
I tried handling the RESULT_RECONNECT_REQUIRED code in my onActivityResult, but nothing changes.
@Override
public void onActivityResult(int request, int response, Intent data) {
super.onActivityResult(request, response, data);
GameHelper helper = resolver.getGameServicesHelper();
if (helper != null) {
helper.onActivityResult(request, response, data);
}
if (response == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
helper.disconnect();
}
}
The leaderboards activities start correctly and work flawlessly.
Found the problem... it wasn't a problem in my app, just the Google Play Games app on my device had some corrupted data or something. I followed the steps here and that fixed it. http://howlukeseesit.blogspot.it/2014/08/fixing-google-play-games.html
- First navigate to settings > apps and find and tap on Google play games.
- Next tap uninstall updates, then tap clear data.
- Next go back to the apps section and find Google Play Services, tap that then tap Manage space and then tap on clear all data.
- Now all you have to do is go into the Play store and manually update Google Play Games.
来源:https://stackoverflow.com/questions/25507922/google-play-games-services-achievement-activity-closing-immediately