cerco di lavorare con l'API di Google Drive su Android, in primo luogo con la demo:API Android di Google Drive "connessione non riuscita"
https://github.com/googledrive/android-quickstart
Tuttavia, ho questo errore che non riesco a risolvere.
collegamento GoogleApiClient fallita: ConnectionResult {statusCode = SIGN_IN_REQUIRED, risoluzione = {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;
}
}
Nel mio caso, questo errore è stato causato da qualcosa del pacchetto dell'app che non corrisponde a quello nella credenziale. È necessario assicurarsi che il nome del pacchetto e SHA1 devono corrispondere. La versione di debug in esecuzione su una macchina di sviluppo può avere un nome di pacchetto diverso e SHA1 da quella della versione di rilascio. – Hong