0

I'm making an Android App using Eclipse. I want to implement a feature that shares a file on my dropbox account so I downloaded the sdk.

I'm following official documentation here: https://www.dropbox.com/developers/start/authentication#android

so I wrote this code in Import Section:

import com.dropbox.client2.DropboxAPI;
import com.dropbox.client2.android.AndroidAuthSession;
import com.dropbox.client2.session.AppKeyPair;
import com.dropbox.client2.session.Session.AccessType;

This code in classe declaration

final static private String APP_KEY = "*****";
final static private String APP_SECRET = "****";
private DropboxAPI<AndroidAuthSession> mDBApi;

and this code in my method:

com.dropbox.client2.session.AppKeyPair appKeys = new com.dropbox.client2.session.AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeys,AccessType.APP_FOLDER);
mDBApi = new DropboxAPI<AndroidAuthSession>(session);

But when I debug first line of method I have this error:

01-02 17:07:54.459: E/dalvikvm(19602): Could not find class 'com.dropbox.client2.session.AppKeyPair', referenced from method com.example.myfirstapp.DbAccess.ShareDbOnDropbox

Please, can you help me?

Thank you very much!

Daniele
  • 203
  • 6
  • 20

2 Answers2

0

When adding the .jar file to your project, do you export the jar on the build path?

Right click your project in Eclipse, select Properties, then select Java Build Path. Navigate to the Order and Export tab and make sure that the Dropbox library is ticked.

This exports the classes for use in your project when the application is compiled and built.

Click Ok, then do a clean build and try again.

biddulph.r
  • 5,226
  • 3
  • 32
  • 47
  • Thank you biddulph.r! It work! The error no longer occurs, but does not do what I expect. Now I do some tests and let you know. For now, thank you! – Daniele Jan 02 '13 at 17:05
-1

Change this:

 com.dropbox.client2.session.AppKeyPair appKeys = new com.dropbox.client2.session.AppKeyPair(APP_KEY, APP_SECRET);

to this:

 AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);

in Eclipse press

 ctrl + shift + O

this will organise your imports and bring in the correct DropBox class, if it does then yay fixed. If it doesn't then your class path is not setup correctly and your project can't find the dropbox lib/jar/sdk.

Blundell
  • 75,855
  • 30
  • 208
  • 233
  • not really. according to dropbox documentation, that's the correct qualified name. – njzk2 Jan 02 '13 at 16:49
  • @njzk2 yes but he manually typed the imports himself, so he doesn't know if his classpath is correct or not. The outcome of ctrl+shift+O would give us this hint – Blundell Jan 02 '13 at 16:50
  • it wouldn't compile if the imports were wrong. the issue here is obviously about exporting at compile time. – njzk2 Jan 02 '13 at 16:51
  • @njzk2 good point :-p I was just thinking some people don't actually realise when they have compile errors, but yeah his issue is not compile time it's run time – Blundell Jan 02 '13 at 16:52
  • Blundell, thi fix don't solve the problem. Originally the code was like the one you posted, I changed it to try. Thanks anyway – Daniele Jan 02 '13 at 17:06