简体   繁体   中英

Unity Facebook SDK Fatal error after Facebook webview login

UPDATE: I've removed the Facebook plugin and went with more platform native solutions

I'm having issues with Facebook Unity SDK V6.2.1 in my Unity project.

I've set up a button where the user can tap on to share his/her score on their Facebook feed. Whenever the user taps on the 'share' button it asks for their Facebook credentials. When the user accepts the required permissions the game crashes with a fatal error.

This is the code I use to let the user log in:

    private void ShareButton() {
        if (!FB.IsLoggedIn) {
            FB.Login();
            if (FB.UserId != null) {
                onBragClicked();
            }
        } else {
            if (FB.UserId != null) {
                onBragClicked();
            }
        }

}

private void onBragClicked() {
    FB.Feed(
            linkCaption: "Test caption" + Score.localScore.ToString() + "! I challenge you to go higher :)",
            picture: "http://i.imgur.com/CgRBQ0W.jpg",
            linkName: "Checkout my new score!",
            link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
            );
}  

These are the logcat results:

--------- beginning of crash

E/AndroidRuntime( 4767): FATAL EXCEPTION: main

E/AndroidRuntime( 4767): Process: com.company.game, PID: 4767

E/AndroidRuntime( 4767): java.lang.Error: FATAL EXCEPTION [main]

E/AndroidRuntime( 4767): Unity version     : 4.6.3p3

E/AndroidRuntime( 4767): Device model      : LGE Nexus 5

E/AndroidRuntime( 4767): Device fingerprint: google/hammerhead/hammerhead:5.1/LMY47D/1743759:user/release-keys

E/AndroidRuntime( 4767): 

E/AndroidRuntime( 4767): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/content/LocalBroadcastManager;

E/AndroidRuntime( 4767):    at com.facebook.Session.postActiveSessionAction(Session.java:1570)

E/AndroidRuntime( 4767):    at com.facebook.Session.postStateChange(Session.java:1559)

E/AndroidRuntime( 4767):    at com.facebook.Session.finishAuthorization(Session.java:1498)

E/AndroidRuntime( 4767):    at com.facebook.Session.finishAuthOrReauth(Session.java:1468)

E/AndroidRuntime( 4767):    at com.facebook.Session.handleAuthorizationResult(Session.java:1330)

E/AndroidRuntime( 4767):    at com.facebook.Session.onActivityResult(Session.java:741)

E/AndroidRuntime( 4767):    at com.facebook.unity.FBLogin.onActivityResult(FBLogin.java:245)

E/AndroidRuntime( 4767):    at com.facebook.unity.FBUnityLoginActivity.onActivityResult(FBUnityLoginActivity.java:25)

E/AndroidRuntime( 4767):    at android.app.Activity.dispatchActivityResult(Activity.java:6192)

E/AndroidRuntime( 4767):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3570)

E/AndroidRuntime( 4767):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3617)

E/AndroidRuntime( 4767):    at android.app.ActivityThread.access$1300(ActivityThread.java:151)

E/AndroidRuntime( 4767):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1352)

E/AndroidRuntime( 4767):    at android.os.Handler.dispatchMessage(Handler.java:102)

E/AndroidRuntime( 4767):    at android.os.Looper.loop(Looper.java:135)

E/AndroidRuntime( 4767):    at android.app.ActivityThread.main(ActivityThread.java:5254)

E/AndroidRuntime( 4767):    at java.lang.reflect.Method.invoke(Native Method)

E/AndroidRuntime( 4767):    at java.lang.reflect.Method.invoke(Method.java:372)

E/AndroidRuntime( 4767):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

E/AndroidRuntime( 4767):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

E/AndroidRuntime( 4767): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.LocalBroadcastManager" on path: DexPathList[[zip file "/data/app/com.company.game-2/base.apk"],nativeLibraryDirectories=[/data/app/com.company.game-2/lib/arm, /vendor/lib, /system/lib]]

E/AndroidRuntime( 4767):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

E/AndroidRuntime( 4767):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

E/AndroidRuntime( 4767):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)

E/AndroidRuntime( 4767):    ... 20 more

E/AndroidRuntime( 4767):    Suppressed: java.lang.ClassNotFoundException: android.support.v4.content.LocalBroadcastManager

E/AndroidRuntime( 4767):        at java.lang.Class.classForName(Native Method)

E/AndroidRuntime( 4767):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)

E/AndroidRuntime( 4767):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)

E/AndroidRuntime( 4767):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

E/AndroidRuntime( 4767):        ... 21 more

E/AndroidRuntime( 4767):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

W/ActivityManager(23145):   Force finishing activity 1 com.company.game/com.facebook.unity.FBUnityLoginActivity

Specs:

  • Facebook SDK v6.2.1
  • Unity 4.6.3p3

Thanks in advance for any help!

Is your game live or not?

When doing facebook stuff from unity, you have to copy and paste a code they give you from the website each time you log in from the unity editor. I am assuming everything is already setup with facebook. Also make sure the account you are using has access to the game, they should be a developer or admin (FB should explain this part to you) and make sure the account lets the app actually do wall posts. Facebook has weird settings to not allow apps to perform certain functions.

Lastly, I do not see FB.Init, so I am also assuming you did this somewhere. If this isnt called, this will create issues when trying to use the FB class.

Hope this helps and/or leads you in the right direction. Good luck, getting FB to work can be tricky.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM