For completeness
I'm guessing you got to this exception by following the code example from Google Drive QuickStart. If so you'll might find the following things I had to modify interesting.
Google Play Services Lib (NB. See comment below!)
The documentation uses the old way of adding libraries to an Android project. This will fail when executed with the latest ADT. You will be able to compile and upload to the device/emulator but on execution you'll get a NoClassDefFoundError.
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/AccountPicker;
To fix this you should copy paste the google-play-services.jar
file to the libs
folder instead.
Missing meta-tag
Up to the next error. I then received an IllegalStateException
with the instructions to add a meta-tag in the manifest holding the google-play-services version.
So within the application tag of the manifest add:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
And in one of the resource files (res/values/a-file-here.xml
) add the following:
<integer name="google_play_services_version">4030500</integer>
In my case the lib matched this version. If you enter the wrong version here you'll get an error showing the proper version to specify. So make sure to check output.
Permission Denied
Finally I got a prompt for oauth in the app just to find out the example app is still missing a permission. The error for reference:
java.io.FileNotFoundException: /storage/emulated/0/Pictures/IMG_20131211_110629.jpg: open failed: EACCES (Permission denied)
Next to the permissions listed within the example:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
Also add the WRITE_EXTERNAL_STORAGE permission in your manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
More resources
If you get an com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException
exception with in the root cause somewhere a description Unknown
you should check the settings in the Google API console. I received this error on a package mismatch.
Another links of interest are the oauth2 documentation and the google api playground.