Search code examples
apitabletnexussamsung-mobilegoogle-drive-android-api

Google Drive API only working on tablet, not smartphone


I have created an app that connects to Google Drive via this code:

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

googleApiClient.connect();

This code works on my tablet (Samsung Galaxy Tablet 2, with 4.4.2 running on it), however when I try running this same code on either a Nexus 5 with 5.0.1 or a Galaxy S5 with 4.4.4, connecting to Google Drive crashes every time.

I do one initialization of the googleApiClient object, and one call to connect, but for some reason I keep getting this error:

04-13 15:27:44.563: E/AndroidRuntime(5402): java.lang.IllegalStateException: Client must be connected

Both phones have 3G and Wifi access, and the tablet just has Wifi access. I am calling connect to Google Drive, but for some reason I keep getting this error.

Has anyone ever encountered this issue before?


Solution

  • I believe your problem stems from a mismatch in Google Play Services versions. I think, the 7.0.+ version on your phone needs revision 23 in your IDE. Try to run SDK Manager and download rev 23 or higher. Your tablet will probably update to 7.00.+ when Google decides the time is right. But rev. 23 (or higher) should be compatible with everything 7.00 and lower. I can't be more specific here, since I am on Android Studio.

    Good Luck