简体   繁体   中英

How do I get the Dropbox Android API to work with Eclipse?

Whenever I try to run my project, the app crashes with this:

E/dalvikvm(17890): Could not find class 'com.dropbox.client2.DropboxAPI', referenced from method ...
...
...
E/AndroidRuntime(17890): Caused by: java.lang.NoClassDefFoundError: com.dropbox.client2.session.Session$AccessType

I actually had this exact problem a few days ago, but I solved it by taking the dropbox jars off my build path, creating a folder in the root of my project called 'libs' and putting the jars in there. Now, after making no changes to my project setup, running the project causes it to crash again with the same error I had been getting previously.

I've tried removing and re-adding the libs folder (and cleaning). I've tried adding the jars to my build-path, both when they're sourced within the project in the libs folder and also externally somewhere else on my file system. And Eclipse recognizes the dropbox imports, so there's no errors reported. I don't know what else to do.

I am aware of this more-or-less identical question here and this "solution" here . Can anyone suggest anything that I could try? I'm blocked until I can figure this out. I'm running Windows with Eclipse Kepler (I think that's 4.3).

EDIT
It's working again. I checked all the possible options for export in the build-path order/export menu. Previously, only Android Private Libraries and Android Dependencies was checked:

在此处输入图片说明

I'm leaving this open in the hope that someone might tell why this fixed things.

i ran into this problem and figured out that when Dropbox said to add all the .jars under the sdk folder lib/ , you're not supposed to add the ones under lib/extra and lib/test . So the best way to import (IMO) is

  1. Right-Click the Project > Properties > Java Build Path (in sidebar) > "Libraries" tab
  2. "Add Library..." > "User Library" > "User Libaries..." > "New..."
  3. Call it whatever you like, eg "DropboxSDK"
  4. Select the library you just made > "Add External Jars..." > Browse to the lib/ folder you downloaded and extracted, select all the jars under lib/ but don't go into the subfolders
  5. Click "OK" to go back to the "Add Library" window, check the Library you just made > "Finish" > Your new library should be under the "Libraries" tab
  6. Switch to "Order and Export" tab > checkmark your library
  7. Click "OK" to exit & save ur properties, then clean & rebuild your project

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM