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

前端 未结 2 1928
谎友^
谎友^ 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?

提交回复
热议问题