Boardy
Boardy

Reputation: 36205

NoClassDefFoundErrror with Google Drive

I've got a project which had Google Drive included and it was all working perfectly fine. Then I performed an upgrade of the Android SDK and Eclipse ADT Plugin and Google Drivie no longer works and I can't understand why.

I've added the Drive API to my project as well as Google Play Services and tick on the checkbox to export. I've done a clean build, I've deleted the bin directory of my app, restarted eclipse, re-did the clean build but as soon as I run the section of my app which should show the google account chooser the app crashes.

Below is the error returned in the logcat

05-18 17:17:09.089: E/AndroidRuntime(16747): FATAL EXCEPTION: main
05-18 17:17:09.089: E/AndroidRuntime(16747): java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
05-18 17:17:09.089: E/AndroidRuntime(16747):    at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.newChooseAccountIntent(GoogleAccountCredential.java:171)

No matter what I try it doesn't seem to make any difference.

Update

I've tried ticking the export option for Android Private Libraries as Raghunandan suggested. Most of the app is working such as the Dropbox API that is also included in the project but I still get the error when the Google Drive part of the code is executed, with the NoClassDefFoundError.

If I tick the Drive API within the Order & Export Tab I then get an error Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/api/client/googleapis/extensions/android/accounts/GoogleAccountManag‌​er;

Upvotes: 0

Views: 1161

Answers (3)

Steven Huang
Steven Huang

Reputation: 31

I have the same problem, and solved it now.

First I try to download the Dredit, and it works fine!! So I remove the google api from properties (properties->Java Build Path->Libraries). and copy the libs from Dredit. Guess what? the problem still exist.

So I do the following steps to rebuild whole project, and this problem has solved. Hope it can help you.

  1. Remove googe api and all related libs.
  2. Close this project
  3. Open the project folder and remove and hidden folder (start with .) and generated folder
  4. Re-include project again. And Copy the libs form Dredit

Upvotes: 0

ferini
ferini

Reputation: 1958

Looks like you are importing multiple libraries defining class com.google.api.client.googleapis.extensions.android.accounts.GoogleAccountManag‌er. Look into Package Manager, under Android Private Libraries and try opening .jar files there. You will probably find this class in at least two of them (one of them might be something like google-api-client-android-1.13.2-beta.jar).

Try excluding one of the jar files from your build path. If you have no errors, you are done. If there are errors, try excluding the other jar file. If errors remain, you can try opening jar as zip and manually deleting the GoogleAccountManager.class file.

Upvotes: 2

Raghunandan
Raghunandan

Reputation: 133560

Try going to Project -> Properties -> Order & Export and ensure Android Private Libraries are checked for your project and for all other library projects you are using.

Upvotes: 1

Related Questions