2

I'm trying to show achievements on my Android app. I'm using method for this provided by https://developers.google.com/games/services/android/achievements

private void showAchievements() {
    System.out.println("start showAchievements");
    Games.getAchievementsClient(this, GoogleSignIn.getLastSignedInAccount(this))
        .getAchievementsIntent()
        .addOnSuccessListener(new OnSuccessListener<Intent>() {
            @Override
            public void onSuccess(Intent intent) {
                System.out.println("in onSuccess");
                startActivityForResult(intent, RC_ACHIEVEMENT_UI);
            }
        });

but when I'm calling the method I'm getting the EXCEPTION:

E/AndroidRuntime: FATAL EXCEPTION: GoogleApiHandler Process: com.my.application PID: 1927 java.lang.IllegalStateException: Games APIs requires https://www.googleapis.com/auth/games_lite function.

I'm thinking that problem form Games.getAchievementsClient() method, but can't fix

  • 1
    Did you go through the document for troubleshooting issues provided by Google? https://developers.google.com/games/services/android/troubleshooting – Al0x Nov 26 '17 at 13:30
  • 1
    I just did it. Everything is correct. It doesn't help. – Davit Vardanyan Nov 26 '17 at 13:54
  • I stumbled over these two answers, maybe they could fix your problem: https://stackoverflow.com/a/16599446/2734302 https://stackoverflow.com/a/36414508/2734302 – Al0x Nov 26 '17 at 14:01
  • 1
    Thanks, but no, my problem is different. My AndroidManifest.xml is currect – Davit Vardanyan Nov 26 '17 at 14:24
  • Hi! I've got your same error with both `getAchievements` and `getPlayersClient`. Did you find any solution? – Oiproks Dec 01 '17 at 13:12
  • @Oiproks I just used the sample from Google and it works. https://developers.google.com/games/services/android/quickstart#step_3_modify_your_code – Davit Vardanyan Dec 01 '17 at 15:34
  • Seems similar to https://stackoverflow.com/questions/47594187/google-play-games – Oleh Kuznetsov Dec 15 '17 at 15:33

1 Answers1

1

It seems your GoogleSignIn.getLastSignedInAccount(this) has no Games.SCOPE_GAMES_LITE.

You can check it by GoogleSignIn.hasPermissions. If there is no such permission you should request it with GoogleSignIn.requestPermissions or receive new account with GoogleSignInClient.silentSignIn.