java.lang.NoClassDefFoundError on Android with GoogleAccountCredential.newChooseAccountIntent()

前端 未结 2 1929
谎友^
谎友^ 2021-01-14 05:02

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.

相关标签:
2条回答
  • 2021-01-14 05:45

    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?

    0 讨论(0)
  • 2021-01-14 05:50

    OK, I've found out what I was missing.

    1. Ensure you have downloaded the Android SDK Services -> Extras -> Google Play services

    2. 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

    0 讨论(0)
提交回复
热议问题