I am developing for Android 4+ with Eclipse Juno ADT bundle + Google Plugin for Eclipse. I need to programmatically log into a google account to use the Google Calendar API.
I've run into a similar problem lately. My app (not in production yet) would suddenly (since the beginning of May) start throwing uncatchable 'NoClassDefFoundError' error when calling
GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE_FILE)
method. It was happening randomly, usually first time in the morning. I could fix it by re-installing my Google account. Not a good solution for production, though. I've spent frustrating couple of hours trying to resolve it until I finally realized I have another app that does not have the same problem in the same code sequence. So I diff-ed both of them and realized that the "good" one had a different sequence of entries in 'Package Explorer->Project->Properties->Java Build Path' The 'good' one had
'google-play-services.jar' BEFORE 'android-support-v4.jar',
where the 'bad' one had it backwards. So I switched the sequence (using UP, DOWN buttons in the dialog) and it seems to solve the problem. Yet another WT... ? moment! Does anybody have an opinion on this?
OK, I've found out what I was missing.
Ensure you have downloaded the Android SDK Services -> Extras -> Google Play services
Follow the instructions provided by the following link to add the google-play-services-lib library to your project:
http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject
Best Regards