EDIT: It is working perfectly fine on my tablet and another phone. So the issue is related to the device. Any ideas? I already reinstalled all google play related apps multiple times with no success :/
When I try to connect the GoogleApiClient
I always get
onConnectionFailed:ConnectionResult{statusCode=RESOLUTION_REQUIRED, resolution=PendingIntent{13c5b37: android.os.BinderProxy@e07c8a4}, message=null}
When I run
connectionResult.startResolutionForResult(this, RC_RESOLUTION);
the Intent
data is null
.
I'm pretty lost here what is going wrong here and what RESOLUTION_REQUIRED
actually means in this context.
Maybe this helps: If I try the same with the Drive.API
I get a SIGN_IN_REQUIRED
error which seems to be a much more common error.
Any ideas would be highly appreciated!
package com.some.domain.signin;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;
import com.some.domain.activity.MainActivity;
import com.some.domain.application.ApplicationClass;
public class GoogleSignInActivity extends Activity implements GoogleApiClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks {
private static final String TAG = "T1_GSignInActivity";
private static final int RC_RESOLUTION = 9002;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "GoogleSignInActivity");
setupGoogleClient();
}
public static GoogleApiClient googleApiClient;
public void setupGoogleClient() {
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();
ApplicationClass.getInstance().setGoogleClient(googleApiClient);
}
@Override
public void onStart() {
super.onStart();
googleApiClient.connect();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_RESOLUTION){
startNextActivity();
}
}
private void startNextActivity() {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Toast.makeText(this, "Connection failed:\n" + connectionResult.toString(), Toast.LENGTH_LONG ).show();
try {
connectionResult.startResolutionForResult(this, RC_RESOLUTION);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
Log.d(TAG, "onConnectionFailed:" + connectionResult);
}
@Override
public void onConnected(@Nullable Bundle bundle) {
Toast.makeText(this, "Connected.", Toast.LENGTH_LONG ).show();
}
@Override
public void onConnectionSuspended(int i) {
Toast.makeText(this, "Connection Suspended.", Toast.LENGTH_LONG ).show();
}
}
Alright so after I struggled for like two days it turns out I got it fixed by reinstalling the google play services and the google play store. I came to realize this after I got the program run on two different devices without issues...
Also ensure the following:
Google API: I registered my debug and my release certificate as Open Auth2 (SHA-1)
Google Play: I connected the game in the "PlayServices" with the package name of my game
Google-Services.json: Is copied into the app folder and contains all my certificates (SHA-1)
Tester: I'm registered as tester