Ich versuche, mit der API Google Drive auf Android zu arbeiten, zuerst die Demo mit:Android API Google Drive "Verbindung fehlgeschlagen"
https://github.com/googledrive/android-quickstart
Allerdings habe ich diesen Fehler, die ich nicht lösen kann.
GoogleApiClient Verbindung fehlgeschlagen: Connection {status = SIGN_IN_REQUIRED, Auflösung = PendingIntent {421d40e8: [email protected]}}
@Override
public void onConnectionFailed(ConnectionResult result) {
// Called whenever the API client fails to connect.
Log.i(TAG, "GoogleApiClient connection failed: " + result.toString());
if (!result.hasResolution()) {
// show the localized error dialog.
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show();
return;
}
// The failure has a resolution. Resolve it.
// Called typically when the app is not yet authorized, and an
// authorization
// dialog is displayed to the user.
try {
result.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
} catch (SendIntentException e) {
Log.e(TAG, "Exception while starting resolution activity", e);
// There was an error with the resolution intent. Try again.
mGoogleApiClient.connect();
}
}
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
if (requestCode == REQUEST_CODE_RESOLUTION) {
if (resultCode == RESULT_OK) {
Log.i(TAG, "Error resolution success.");
// Make sure the app is not already connected or attempting to connect
if (!mGoogleApiClient.isConnecting() &&
!mGoogleApiClient.isConnected()) {
mGoogleApiClient.connect();
}
} else {
GooglePlayServicesUtil.getErrorDialog(requestCode, this, 0).show();
}
break;
}
}
In meinem Fall fahren gehen kann, wurde dieser Fehler verursacht durch etwas des App-Pakets, das nicht mit dem Berechtigungsnachweis übereinstimmt. Man muss sicherstellen, dass der Paketname und SHA1 übereinstimmen müssen. Die Debug-Version, die auf einem Dev-Computer ausgeführt wird, hat möglicherweise einen anderen Paketnamen und SHA1 als die Versionsnummer. – Hong