android Facebook SDK崩溃的应用程序?

时间:2014-03-28 10:46:16

标签: android facebook

我正在尝试在我的应用程序中添加facebook登录,我在此示例中遵循了所有内容

https://developers.facebook.com/docs/android/login-with-facebook/

我也已经下载了sdk并且所有示例都运行良好,

但我的问题是当我尝试将示例项目中的所有内容复制到我的项目时,如果我添加FaceBook会话,我的应用程序崩溃了

 Session session = Session.getActiveSession();

 if (session == null) {
     if (savedInstanceState != null) {
         session = Session.restoreSession(this, null, statusCallback, savedInstanceState);
     }
     if (session == null) {
         session = new Session(this);
     }
     Session.setActiveSession(session);
     if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
         session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
     }
 }

这是日志:

03-28 12:42:32.209: E/AndroidRuntime(8613): FATAL EXCEPTION: main
03-28 12:42:32.209: E/AndroidRuntime(8613): java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
03-28 12:42:32.209: E/AndroidRuntime(8613):     at com.facebook.Session.postActiveSessionAction(Session.java:1328)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at com.facebook.Session.setActiveSession(Session.java:790)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at com.dow.dowjstest.MainActivity.onCreate(MainActivity.java:72)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.app.Activity.performCreate(Activity.java:5372)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.app.ActivityThread.access$700(ActivityThread.java:159)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.os.Looper.loop(Looper.java:176)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at android.app.ActivityThread.main(ActivityThread.java:5419)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at java.lang.reflect.Method.invoke(Method.java:525)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
03-28 12:42:32.209: E/AndroidRuntime(8613):     at dalvik.system.NativeStart.main(Native Method)
03-28 12:42:32.264: I/GATE(8613): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>

2 个答案:

答案 0 :(得分:2)

库“android-support-v4.jar”在Facebook lib项目和你的项目中应该是相同的。 因为看起来不同的项目使用2个独立的支持库,并且校验和不同。

有关详细信息,请查看Facebook SDK for Android duplicate support library on dependencies

希望这会有所帮助..

答案 1 :(得分:1)

花了几个小时搜索这个问题后,问题是我必须从Facebook libs复制android-support-v4.jar并在我的项目中用android-support-v4.jar替换它,这对我有用,但我不知道为什么< / p>