Android Drive GooglePlayServicesUtil: The specified account could not be signed

I need to use the api disk to create a file with some content from my application, so I skipped to the Getting Started section from the Api disk webpage.

So I enabled the api in my developer console, created an OAuth client id as he says. (Can the api be used if I haven't paid 2 $ 5 yet?)

In my settings activity by onCreate method that I do:

 googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Drive.API)
            .addScope(Drive.SCOPE_FILE)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

      

I am implementing methods:

@Override
protected void onStop(){
    getGoogleApiClient().disconnect();
    super.onStop();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean(STATE_RESOLVING_ERROR, resolvingError);
}

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (resolvingError) {
        // Already attempting to resolve an error.
        return;
    }else if (connectionResult.hasResolution()) {
        try {
            resolvingError = true;
            connectionResult.startResolutionForResult(this,RESOLVE_CONNECTION_REQUEST_CODE);
        } catch (IntentSender.SendIntentException e) {
            getGoogleApiClient().connect();
        }
    } else {
        GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
        resolvingError = true;
    }
}

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if(requestCode == RESOLVE_CONNECTION_REQUEST_CODE) {
        resolvingError = false;
        if (resultCode == RESULT_OK) {
            if(!getGoogleApiClient().isConnecting() && !getGoogleApiClient().isConnected()){
                getGoogleApiClient().connect();
            }
        }
    }
}

@Override
public void onConnected(Bundle bundle) {
    Toast.makeText(this, "Success!!! :D :D", Toast.LENGTH_SHORT).show();
}

@Override
public void onConnectionSuspended(int i) {}

      

Then I call googleApiClient.connect (); by onclick method.

I am getting google select account drive dialog, select account and click OK and I am getting this error on connection result:

E / GooglePlayServicesUtil: The specified account could not be signed.

I have searched through the internet and could not find the cause of this problem .... maybe I am doing something wrong in the developer console ... I don’t know ...

UPDATE:

So, I delete the project in google developer console and build it again, I also add Drive Api and enable it, add product name on login screen and new client id with my package name and sha1 id ...

also updates my manifest,

added to manifest tag:

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />   
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

      

to the application tag:

<meta-data
       android:name="com.google.android.gms.version"
       android:value="@integer/google_play_services_version"/>

      

to the activity tag where im doing the connection:

<meta-data
       android:name="com.google.android.apps.drive.APP_ID"
       android:value="id=<app id i took this id from developers´console>" />
<action android:name="com.google.android.apps.drive.DRIVE_OPEN" />
<data android:mimeType="application/vnd.google-apps.drive-sdk.<app id>" />

      

I am also building a signed apk using the debug repository for testing my application. (on a real device).

after that the error is still growing ...

+3


source to share


7 replies


I am guessing there is a problem with the setup you made in the developer console. This discussion may be helpful. - qbix

hi after reading the qbix discussion mentioned above i just found the cause of my problem ...

there was a wrong app id in my project structure by default, I just change it to my app package "com.xxxxx.yyyyy".



so I beleave when googleApiClient tried to connect, find a different package name in the client ids of the client and deny access ....

now works fine thanx ....

+2


source


Here's my usual checklist:

1 / get the APK in question, push it through unzipper like 7-zip. you will find a META-INF folder with a CERT.RSA file. Get this.

2 / run ' keytool -printcert -file ...... \ CERT.RSA ' and copy / save SHA1 '11.22.33 ... 99 >

3 / get package name (from manifest?) ' Com.blabla.yourproject '



4 / open console console ' https://console.developers.google.com/project '

5 / in your project, check:

  • Included APIs: Drive API
  • Credentials : Package name: com.blabla.yourproject ', Fingerprint : 11.22.33 ... 99 '
  • Consent Screen: Email: yourmail@gmail.com , Product Name: 'YourProject'

Luck

+1


source


Please try a regular Google account first.

mGoogleApiClient = new GoogleApiClient.Builder(this).
addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(new Scope(Scopes.PROFILE))
//.addApi(Drive.API)
//.addScope(Drive.SCOPE_FILE)
.build();

      

0


source


In my case the reason was the wrong package name in the OATH client settings: was: com.blabla.prog correct: bla.bla.com.prog

0


source


try to ignore the API connection by doing the following:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApiIfAvailable(Drive.API)

      

I did like this and everything works. I don't really know why, I suppose Driver.API is causing some problems and that way you can use maps, markers and all that. I know this is not a very good answer because I am not giving you the correct explanation, but it might help anyway.

0


source


This type of error can occur in the following situations:

  • If you used the SHA1 debug key of certificate-to-cert signing when generating the Oauth 2.0 client ID and running your app without signing it with the release key (i.e. working with the debug key). This is also true for the debug key.
  • If you used a different package name when creating the Oauth 2.0 client ID
0


source


Another thing that can go wrong is that you create credentials for "API Key" instead of "OAuth 2.0 Client ID".

Yes, silly I know .. the manual says "Client ID" so I guess I went down the length of the line :)

0


source







All Articles