Android & Eclipse Error: Could not find class 'com.dropbox.client2.session.AppKeyPair'

孤街醉人 提交于 2019-12-11 19:16:03

问题


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!


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/14125694/android-eclipse-error-could-not-find-class-com-dropbox-client2-session-appke

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!