Android API Google Drive "connection failed"

android, google-drive-api

Solution

This may be due to negligence on developer's part (as it happened with me) - the SHA1 details you provide on the console are that of production key and you are testing on Debug mode (the SHA1 details would be different). The error message google drive API, gives could have been better, though!

Problem

I try to work with the API Google Drive on Android, first using the demo: https://github.com/googledrive/android-quickstart However, I have this error that I can not solve . GoogleApiClient connection failed: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{421d40e8: android.os.BinderProxy@42137f78}} ``` @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; } } ```

Original source