Davit Vardanyan
Davit Vardanyan

Reputation: 21

Google Play Game Services showAchievments()

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

Upvotes: 2

Views: 825

Answers (1)

Oleh Kuznetsov
Oleh Kuznetsov

Reputation: 91

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.

Upvotes: 1

Related Questions