Kodr.F
Kodr.F

Reputation: 14370

android Facebook SDK Crashing the application?

I am trying to add facebook login in my application , i followed every thing at this example

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

also I've Downloaded the sdk and all examples are working fine ,

But my problem is when i attempt to copy every thing from the example project to my project , my application crashed if i added FaceBook session

 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));
     }
 }

this is the log :

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>

Upvotes: 2

Views: 1748

Answers (2)

Virag Brahme
Virag Brahme

Reputation: 2062

The library 'android-support-v4.jar' should be same in both Facebook lib project and your project. because it seems like the different projects are using 2 separate support libraries and there checksum is different.

For more details check Facebook SDK for Android duplicate support library on dependencies

Hope this helps..

Upvotes: 2

Kodr.F
Kodr.F

Reputation: 14370

after spending hours searching for this issue, the problem was i have to copy android-support-v4.jar from Facebook libs and replace it with android-support-v4.jar in my project , this worked for me but i have no idea why

Upvotes: 1

Related Questions