简体   繁体   中英

Integrating Google Snapshot API to Android App causes in com.google.android.gms.common.api.ResolvableApiException: 4: 4:

I am currently developing an Android App. It already uses Google Play Games (Leaderboards, Achievements and a TurnBased-Multiplayer are already integrated and work fine). Now I want to save some GameData where I want to use Snapshot API for.

I always sign a release version and upload it to google play for a group of testers and all worked fine until I tried to add the Snapshot API.

What I did:

  • I turned Saved Games to on in Google Play Console in Play Services
  • I activated Google Drive API in Google Cloud platform
  • I added .requestScopes(Drive.SCOPE_APPFOLDER) to my GoogleSignInMethode (this is why the Error comes)
private void signInToGoogle() {
mGoogleClient = GoogleSignIn.getClient(this,
        new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
                .requestScopes(Drive.SCOPE_APPFOLDER)
                .build());
signInSilently();
}

private void signInSilently() {
System.out.println("A7DE signInSilently()");

mGoogleClient.silentSignIn().addOnCompleteListener(this,
        new OnCompleteListener<GoogleSignInAccount>() {
            @Override
            public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
                if (task.isSuccessful()) {
                    System.out.println("A7DE signInSilently(): success");
                    onConnected(task.getResult());
                } else {
                    System.out.println("A7DE signInSilently(): failure "+task.getException());
                    Log.e(TAG, "Exception: "+Log.getStackTraceString(task.getException()));
                    onDisconnected();
                }
            }
        });
}

With that code Logcat says:

09-06 13:59:15.632 14860-14860/? I/System.out: A7DE signInSilently(): failure com.google.android.gms.common.api.ResolvableApiException: 4: 4: 
09-06 13:59:15.633 14860-14860/? E/StatsACT: Exception: com.google.android.gms.common.api.ResolvableApiException: 4: 4: 
     at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
     at com.google.android.gms.common.internal.zzk.convert(Unknown Source)
     at com.google.android.gms.common.internal.zzl.onComplete(Unknown Source)
     at com.google.android.gms.common.api.internal.BasePendingResult.zza(Unknown Source)
     at com.google.android.gms.common.api.internal.BasePendingResult.setResult(Unknown Source)
     at com.google.android.gms.auth.api.signin.internal.zzk.zzd(Unknown Source)
     at com.google.android.gms.auth.api.signin.internal.zzu.dispatchTransaction(Unknown Source)
     at com.google.android.gms.internal.auth.zze.onTransact(Unknown Source)
     at android.os.Binder.execTransact(Binder.java:573)
09-06 13:59:15.633 14860-14860/? I/System.out: A7DE disconnected...

To make it even more inaudible, this throws only the Error on S6 Android 7. Also tested it with A5 Android 8 and there it works perfectly...

For me this is a very rare problem but I hope that you can help me find a solution.

Thanks in advance

I found the solution for me. The problem was that the permissions on the S6 where not granted for Using Google Drive. Now I am first checking if the User already has gave permission and than open the GoogleSignInClient with the Drive.SCOPE_APPFOLDER.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM