Reputation: 21
I tried to connect my app with Google play services, first off all to log in with Google+ account. The loading screen for the play services on connect appears, but somehow the googleApiClient doesn't connect, i always come to the method "onConnectionFailed".
Dependencies in Gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.1'
compile 'com.android.support:support-v4:21.0.1'
compile 'com.google.android.gms:play-services-appinvite:7.8.+'
compile 'com.google.android.gms:play-services:7.8.+'
compile 'com.google.android.gms:play-services-drive:7.8.+'
onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multiplayer_turn_based);
//signInButton = (Button) findViewById(R.id.sign_in_button);
findViewById(R.id.sign_in_button).setOnClickListener(this);
findViewById(R.id.sign_out_button).setOnClickListener(this);
buttonCheckGames = (Button) findViewById(R.id.buttonCheckGames);
buttonStartMatch = (Button) findViewById(R.id.buttonStartMatch);
// Create the Google API Client with access to Plus and Games
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER)
.setViewForPopups(findViewById(android.R.id.content))
.build();
}
for sign in:
public void onClick(View v) {
switch (v.getId()) {
case R.id.sign_in_button:
mSignInClicked = true;
mTurnBasedMatch = null;
mGoogleApiClient.connect();
break;
case R.id.sign_out_button:
mSignInClicked = false;
Games.signOut(mGoogleApiClient);
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_button).setVisibility(View.GONE);
break;
default:
break;
}
}
@Override
protected void onStart() {
super.onStart();
// Log.d(TAG, "onStart(): Connecting to Google APIs");
mGoogleApiClient.connect();
}
There login screen appears for "Play Games" as a popup, but it doesn't connect due to "unknown problem with Google Play services" error.
I configured the App with the dev console using: https://developers.google.com/games/services/console/enabling , sha1 key and app_id are involved, but I don't know what the problem is :/ Testing on external advice with Android API 21, latest "Play Games"-version and internet access. Maybe someone can help me, want to implement this is my bachelor thesis.
Upvotes: 0
Views: 565
Reputation: 21
Ok the problem was i tried to connect over a second Activity, i tried it again in the main Activity and it works :)
Upvotes: 2