Blackberry Facebook SDK throwing exception: NoClassDefFoundError

亡梦爱人 提交于 2019-12-12 14:00:44

问题


I've searched through all the topics related to my question but couldn't find a solution to it. I'm coding for a Blackberry app using the BlackBerry Java Plug-in for Eclipse v1.5.2 with JRE 7.1.0. I'm currently trying to integrate Facebook Connect into my app so that the users can log into our app through Facebook. The Blackberry Facebook SDK that I'm using is version 0.8.25 downloaded from here:

http://sourceforge.net/projects/facebook-bb-sdk/

After getting the two jar files, FacebookBlackberrySDK-v0.8.25.jar and Log4B-v0.9.4.jar I first preverified them with eclipse successfully and included them into my project as libraries. The project compiled successfully but then I got a run time error: NoClassDefFoundError. After debugging, I found out that the exception was thrown at this line:

fb = Facebook.getInstance(new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, Facebook.Permissions.ALL_PERMISSIONS));

and I suspect that the program couldn't find the file Facebook.class below is my source code:

package com.nextmobile.ecourage.net;

import com.blackberry.facebook.ApplicationSettings;
import com.blackberry.facebook.Facebook;

public class FacebookLogin
{
    private final String NEXT_URL = "http://www.facebook.com/connect/login_success.html";
    private final String APPLICATION_ID = "153555168010272";
    private final String APPLICATION_SECRET = "354f91a79c8fe5a8de9d65b55ef9aa1b";
    private Facebook fb;
    private Facebook fb4u;

    public FacebookLogin()
    {
        fb = Facebook.getInstance(new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, Facebook.Permissions.ALL_PERMISSIONS));
        fb4u = Facebook.getInstance(new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, Facebook.Permissions.USER_DATA_PERMISSIONS));
        fb4u.addPermission(Facebook.Permissions.OFFLINE_ACCESS);
    }
}

So I replaced those lines with only this line of code:

new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, Facebook.Permissions.ALL_PERMISSIONS);

and it worked without giving any error. It's weird cause both Facebook.class and ApplicationSettings.class were in the same directory and the program could find ApplicationSettings.class but not Facebook.class.

both classes are under the package: com.blackberry.facebook

Does anyone have any idea on this? Thank you!


回答1:


Since you are using the Java SDK, you should check out this sample provided by RIM on integrating facebook & twitter into your BB apps: https://github.com/blackberry/Samples-for-Java/tree/master/SocialApp




回答2:


Possible reason ApplicationSettings is compiled with higher java version. Check your project properties->java compiler->compiler compliance level -> this must be 1.4



来源:https://stackoverflow.com/questions/11676646/blackberry-facebook-sdk-throwing-exception-noclassdeffounderror

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