GoogleApiClient Verbindung fehlgeschlagen mit statusCode SIGN_IN_REQUIRED
Ich versuche eine Verbindung zu meinem Spiel zu Google paly service aber es sagen mir immer Verbindung fehlgeschlagen mit statusCode SIGN_IN_REQUIRED .
logcat Meldung:
Ich/GooglePlayServicesActiv﹕ GoogleApiClient Verbindung fehlgeschlagen: ConnectionResult{statusCode=SIGN_IN_REQUIRED, Auflösung=PendingIntent{421a8ce0: android.os.BinderProxy@421939d8}}
Habe ich schon alle nötigen Schritte auf Einrichten Der Google Play Games Services
Plz mir jede Sache, die Es kann, kostet dieses problem .
Class Code:
package com.alnassre.ffeather.android;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.util.Log;
import com.alnassre.ffeather.FFeather;
import com.alnassre.ffhelper.IGoogleServices;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;
import com.google.android.gms.plus.Plus;
public class AndroidLauncher extends AndroidApplication implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
IGoogleServices{
private static final String TAG = "GooglePlayServicesActiv";
private static final String KEY_IN_RESOLUTION = "is_in_resolution";
/**
* Request code for auto Google Play Services error resolution.
*/
protected static final int REQUEST_CODE_RESOLUTION = 1;
/**
* Google API client.
*/
private GoogleApiClient mGoogleApiClient;
/**
* Determines if the client is in a resolution state, and
* waiting for resolution intent to return.
*/
private boolean mIsInResolution;
/**
* Called when the activity is starting. Restores the activity state.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
mIsInResolution = savedInstanceState.getBoolean(KEY_IN_RESOLUTION, false);
}
//main code
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new FFeather(this), config);
}
/**
* Called when the Activity is made visible.
* A connection to Play Services need to be initiated as
* soon as the activity is visible. Registers {@code ConnectionCallbacks}
* and {@code OnConnectionFailedListener} on the
* activities itself.
*/
@Override
protected void onStart() {
super.onStart();
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Games.API)
.addApi(Plus.API)
.addScope(Games.SCOPE_GAMES)
.addScope(Plus.SCOPE_PLUS_LOGIN)
//Optionally, add additional APIs and scopes if required.
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
mGoogleApiClient.connect();
}
/**
* Called when activity gets invisible. Connection to Play Services needs to
* be disconnected as soon as an activity is invisible.
*/
@Override
protected void onStop() {
if (mGoogleApiClient != null) {
mGoogleApiClient.disconnect();
}
super.onStop();
}
/**
* Saves the resolution state.
*/
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_IN_RESOLUTION, mIsInResolution);
}
/**
* Handles Google Play Services resolution callbacks.
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_CODE_RESOLUTION:
retryConnecting();
break;
}
}
private void retryConnecting() {
mIsInResolution = false;
if (!mGoogleApiClient.isConnecting()) {
// mGoogleApiClient.connect();
}
}
/**
* Called when {@code mGoogleApiClient} is connected.
*/
@Override
public void onConnected(Bundle connectionHint) {
Log.i(TAG, "GoogleApiClient connected");
//TODO: Start making API requests.
}
/**
* Called when {@code mGoogleApiClient} connection is suspended.
*/
@Override
public void onConnectionSuspended(int cause) {
Log.i(TAG, "GoogleApiClient connection suspended");
retryConnecting();
}
/**
* Called when {@code mGoogleApiClient} is trying to connect but failed.
* Handle {@code result.getResolution()} if there is a resolution
* available.
*/
@Override
public void onConnectionFailed(ConnectionResult result) {
Log.i(TAG, "GoogleApiClient connection failed: " + result.toString());
if (!result.hasResolution()) {
//Show a localized error dialog.
GooglePlayServicesUtil.getErrorDialog(
result.getErrorCode(), this, 0, new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
retryConnecting();
}
}).show();
return;
}
//If there is an existing resolution error being displayed or a resolution
//activity has started before, do nothing and wait for resolution
//progress to be completed.
if (mIsInResolution) {
return;
}
mIsInResolution = true;
try {
result.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "Exception while starting resolution activity", e);
retryConnecting();
}
}
@Override
public void signIn() {
}
@Override
public void signOut() {
}
@Override
public void rateGame() {
}
@Override
public void submitScore(long score) {
}
@Override
public void showScores() {
}
@Override
public boolean isSignedIn() {
return false;
}
}
Den logcat:
06-29 01:19:41.880 26169-26192/com.alnassre.ffeather.android I/FFeather﹕ created
06-29 01:19:41.910 26169-26192/com.alnassre.ffeather.android I/FFeather﹕ character number:0
06-29 01:19:41.910 26169-26194/com.alnassre.ffeather.android V/SoundPoolThread﹕ Got message m=2, mData=1
06-29 01:19:41.910 26169-26194/com.alnassre.ffeather.android V/MediaPlayer﹕ decode(59, 28840, 16502)
06-29 01:19:41.930 26169-26194/com.alnassre.ffeather.android V/SoundPoolThread﹕ Got message m=2, mData=2
06-29 01:19:41.930 26169-26194/com.alnassre.ffeather.android V/MediaPlayer﹕ decode(60, 45392, 10400)
06-29 01:19:41.945 26169-26194/com.alnassre.ffeather.android V/SoundPoolThread﹕ Got message m=2, mData=3
06-29 01:19:41.945 26169-26194/com.alnassre.ffeather.android V/MediaPlayer﹕ decode(61, 1640, 27150)
06-29 01:19:41.960 26169-26172/com.alnassre.ffeather.android D/dalvikvm﹕ GC_CONCURRENT freed 375K, 8% free 12453K/13511K, paused 2ms+14ms, total 38ms
06-29 01:19:42.065 26169-26169/com.alnassre.ffeather.android I/GooglePlayServicesActiv﹕ GoogleApiClient connection failed: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{421a8ce0: android.os.BinderProxy@421939d8}}
06-29 01:19:42.165 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ unregisterListener:: Listener= com.badlogic.gdx.backends.android.AndroidInput$SensorListener@421403e0
06-29 01:19:42.165 26169-26169/com.alnassre.ffeather.android D/Sensors﹕ Remain listener = Sending .. normal delay 200ms
06-29 01:19:42.165 26169-26169/com.alnassre.ffeather.android I/Sensors﹕ sendDelay --- 200000000
06-29 01:19:42.165 26169-26192/com.alnassre.ffeather.android I/AndroidGraphics﹕ paused
06-29 01:19:42.165 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ JNI - sendDelay
06-29 01:19:42.165 26169-26169/com.alnassre.ffeather.android I/SensorManager﹕ Set normal delay = true
06-29 01:19:42.175 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ unregisterListener:: Listener= com.badlogic.gdx.backends.android.AndroidInput$SensorListener@42196300
06-29 01:19:42.175 26169-26169/com.alnassre.ffeather.android D/Sensors﹕ Remain listener = Sending .. normal delay 200ms
06-29 01:19:42.175 26169-26169/com.alnassre.ffeather.android I/Sensors﹕ sendDelay --- 200000000
06-29 01:19:42.180 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ JNI - sendDelay
06-29 01:19:42.180 26169-26169/com.alnassre.ffeather.android I/SensorManager﹕ Set normal delay = true
06-29 01:19:42.190 26169-26169/com.alnassre.ffeather.android I/AndroidInput﹕ sensor listener tear down
06-29 01:19:42.400 26169-26169/com.alnassre.ffeather.android W/IInputConnectionWrapper﹕ showStatusIcon on inactive InputConnection
06-29 01:19:48.815 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ registerListener :: handle = 0 name= LSM330DLC Acceleration Sensor delay= 20000 Listener= com.badlogic.gdx.backends.android.AndroidInput$SensorListener@421f3558
06-29 01:19:48.825 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ registerListener :: handle = 1 name= AK8963C Magnetic field Sensor delay= 20000 Listener= com.badlogic.gdx.backends.android.AndroidInput$SensorListener@421f3fa0
06-29 01:19:48.825 26169-26169/com.alnassre.ffeather.android I/AndroidInput﹕ sensor listener setup
06-29 01:19:48.860 26169-26192/com.alnassre.ffeather.android I/AndroidGraphics﹕ resumed
06-29 01:19:49.130 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ onAccuracyChanged :: accuracy = 3
06-29 01:19:50.650 26169-26172/com.alnassre.ffeather.android D/dalvikvm﹕ GC_CONCURRENT freed 310K, 7% free 12584K/13511K, paused 12ms+2ms, total 31ms
06-29 01:19:50.650 26169-26192/com.alnassre.ffeather.android D/dalvikvm﹕ WAIT_FOR_CONCURRENT_GC blocked 15ms
06-29 01:20:18.395 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ unregisterListener:: Listener= com.badlogic.gdx.backends.android.AndroidInput$SensorListener@421f3558
06-29 01:20:18.395 26169-26169/com.alnassre.ffeather.android D/Sensors﹕ Remain listener = Sending .. normal delay 200ms
06-29 01:20:18.395 26169-26169/com.alnassre.ffeather.android I/Sensors﹕ sendDelay --- 200000000
06-29 01:20:18.395 26169-26192/com.alnassre.ffeather.android I/AndroidGraphics﹕ paused
06-29 01:20:18.395 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ JNI - sendDelay
06-29 01:20:18.395 26169-26169/com.alnassre.ffeather.android I/SensorManager﹕ Set normal delay = true
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ unregisterListener:: Listener= com.badlogic.gdx.backends.android.AndroidInput$SensorListener@421f3fa0
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android D/Sensors﹕ Remain listener = Sending .. normal delay 200ms
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android I/Sensors﹕ sendDelay --- 200000000
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android D/SensorManager﹕ JNI - sendDelay
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android I/SensorManager﹕ Set normal delay = true
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android I/AndroidInput﹕ sensor listener tear down
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android I/AndroidGraphics﹕ Managed meshes/app: { }
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android I/AndroidGraphics﹕ Managed textures/app: { }
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android I/AndroidGraphics﹕ Managed cubemap/app: { }
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android I/AndroidGraphics﹕ Managed shaders/app: { }
06-29 01:20:18.400 26169-26169/com.alnassre.ffeather.android I/AndroidGraphics﹕ Managed buffers/app: { }
06-29 01:20:18.400 26169-26194/com.alnassre.ffeather.android V/SoundPoolThread﹕ Got message m=1, mData=0
06-29 01:20:18.400 26169-26194/com.alnassre.ffeather.android V/SoundPoolThread﹕ goodbye
06-29 01:20:18.400 26169-26192/com.alnassre.ffeather.android V/SoundPoolThread﹕ return from quit
06-29 01:20:18.405 26169-26192/com.alnassre.ffeather.android V/SoundPoolThread﹕ return from quit
06-29 01:20:18.405 26169-26192/com.alnassre.ffeather.android I/AndroidGraphics﹕ destroyed
06-29 01:20:18.680 26169-26169/com.alnassre.ffeather.android W/IInputConnectionWrapper﹕ showStatusIcon on inactive InputConnection
06-29 01:20:18.860 26169-26169/com.alnassre.ffeather.android W/SurfaceView﹕ CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=false left=false top=false
- Welches Gerät verwendest du zum testen? Der emulator oder ein google play Gerät? Sind Sie angemeldet, in google play?
- Ich bin mit echten Geräten, Samsung Galaxy Nexus und Samsung Galaxy Note II, und ja Singed-in mit dem gleichen Konto.
- Hast du das SO posten? stackoverflow.com/questions/27770243/... Auch dieses: stackoverflow.com/questions/23736137/...
- Ich lösen es, indem Sie "GET_ACCOUNTS" Berechtigung.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Es ist ein weiterer und sehr wichtiger Schritt, dass Anfänger wie mich, der Häufig übersehen wird, in Android studio.
Du manuell angeben müssen, den Keystore, die zum erstellen und signieren der APK, wenn Sie es laufen via Android studio. Dies sollte den gleichen Keystore, deren SHA1-Zertifikat-Signatur, die Sie eingegeben haben, die für die Generierung von API-key in Google Entwickler-Konsole.
Hier ist, wie Sie es tun:
Wenn Sie nicht über eine vorhandene Keystore-ODER kann es nicht finden, können Sie eins erstellen, indem du zu BAUEN -> Generate Signed APK -> Erstellen neue
Haben Sie nach dem erstellen des Keystore, müssen Sie fügen Sie es zu Ihrem Projekt-Einstellungen, so dass es verwendet wird, das zum signieren der APK. Goto Datei -> Projektstruktur -> Wählen Sie Ihr Modul (e.g: app) -> Unterzeichnung
Dann müssen Sie die Unterzeichnung Config, die Sie in Schritt 2 erstellt haben, um Build-Typen
Hoffe, das jemand hilft!
Dass die Lösung gesehen, war nicht auf jedem Dokument, für einen Anfänger wie mich ist es notwendig zu erwähnen,
Hinzufügen der fehlenden Berechtigung :
werden :
Eine einfache Lösung ist, erstellen Sie einfach eine test -
OAuth client ID
mit Android-debug-keystoreSHA-1
.Gehen Sie auf die API-Konsole -> Anmelde -> Erstellen von Anmeldeinformationen -> OAuth-client-ID -> Android
Holen Sie Debug-SHA-1
Passwort
Geben Sie SHA-1 -> Enter-App-Paket-Namen -> Erstellen
Standardmäßig Android studio verwendet diese keystore zum signieren der APK-debug-so sollte es sofort an die Arbeit.