facebook unity sdk 6.0 crash app at second login

北城以北 提交于 2020-01-01 10:11:49

问题


Created a simple app with facebook unity sdk 6.0.

In start function call the init facebook.

There is a button call login and the login callback just output string.

Run on a Samsung galaxy s5 with android 4.4.2.

Issue (100% repeatable):

 1. First time click login button, get the facebook login screen.
 2. Click exit button, back to app.
 3. Click login button again, app crashed.

Crash dump:

W/dalvikvm(16020): threadid=1: thread exiting with uncaught exception (group=0x417f3da0)
V/SmartFaceService - 3rd party pause(  704): onReceive [android.intent.action.ACTIVITY_STATE/com.xxxxx.testfacebook/create]
I/SpenGestureManager(  704): setFocusWindow21055
D/PointerIcon(  704): setMouseIconStyle1 pointerType: 1001iconType:101 flag:0
D/PointerIcon(  704): setMouseCustomIcon IconType is same.101
D/PointerIcon(  704): setHoveringSpenIconStyle1 pointerType: 10001iconType:1 flag:0
D/PointerIcon(  704): setHoveringSpenCustomIcon IconType is same.1
E/AndroidRuntime(16020): FATAL EXCEPTION: main
E/AndroidRuntime(16020): Process: com.xxxxx.testfacebook, PID: 16020
E/AndroidRuntime(16020): java.lang.Error: FATAL EXCEPTION [main]
E/AndroidRuntime(16020): Unity version     : 4.5.3f3
E/AndroidRuntime(16020): Device model      : samsung SAMSUNG-SM-G900A
E/AndroidRuntime(16020): Device fingerprint: samsung/klteuc/klteatt:4.4.2/KOT49H/G900AUCU1ANCE:user/release-keys
E/AndroidRuntime(16020): 
E/AndroidRuntime(16020): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxxxx.testfacebook/com.facebook.unity.FBUnityLoginActivity}: java.lang.UnsupportedOperationException: Session: an attempt was made to open an already opened session.
E/AndroidRuntime(16020):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2328)
E/AndroidRuntime(16020):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
E/AndroidRuntime(16020):    at android.app.ActivityThread.access$900(ActivityThread.java:169)
E/AndroidRuntime(16020):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
E/AndroidRuntime(16020):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(16020):    at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(16020):    at android.app.ActivityThread.main(ActivityThread.java:5476)
E/AndroidRuntime(16020):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(16020):    at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(16020):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
E/AndroidRuntime(16020):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
E/AndroidRuntime(16020):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(16020): Caused by: java.lang.UnsupportedOperationException: Session: an attempt was made to open an already opened session.
E/AndroidRuntime(16020):    at com.facebook.Session.open(Session.java:1223)
E/AndroidRuntime(16020):    at com.facebook.Session.openForPublish(Session.java:519)
E/AndroidRuntime(16020):    at com.facebook.unity.FBLogin.sessionOpenRequest(FBLogin.java:113)
E/AndroidRuntime(16020):    at com.facebook.unity.FBLogin.login(FBLogin.java:98)
E/AndroidRuntime(16020):    at com.facebook.unity.FBUnityLoginActivity.onCreate(FBUnityLoginActivity.java:14)
E/AndroidRuntime(16020):    at android.app.Activity.performCreate(Activity.java:5451)
E/AndroidRuntime(16020):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
E/AndroidRuntime(16020):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
E/AndroidRuntime(16020):    ... 11 more
W/ActivityManager(  704):   Force finishing activity com.xxxxx.testfacebook/com.facebook.unity.FBUnityLoginActivity
I/SQLiteSecureOpenHelper(27856): getWritableDatabase(pwd)
I/SQLiteSecureOpenHelper(27856): getDatabaseLocked(b,b,pwd)...
W/ActivityManager(  704):   Force finishing activity com.xxxxx.testfacebook/com.unity3d.player.UnityPlayerNativeActivity
V/SmartFaceService - 3rd party pause(  704): onReceive [android.intent.action.ACTIVITY_STATE/com.xxxxx.testfacebook/pause]
I/dumpstate(16164): begin
I/SpenGestureManager(  704): setFocusWindow0
D/EnterpriseDeviceManager(  704): ContainerId: 0
D/PointerIcon(  704): setMouseIconStyle1 pointerType: 1001iconType:101 flag:0
D/PointerIcon(  704): setMouseCustomIcon IconType is same.101
D/PointerIcon(  704): setHoveringSpenIconStyle1 pointerType: 10001iconType:1 flag:0
D/CrashAnrDetector(  704): processName: com.xxxxx.testfacebook
D/PointerIcon(  704): setHoveringSpenCustomIcon IconType is same.1
D/CrashAnrDetector(  704): broadcastEvent : com.xxxxx.testfacebook data_app_crash

回答1:


Provided a more permanent solution here on my other account "Helath":

http://answers.unity3d.com/questions/743523/facebook-sdk-cancelled-login-crash.html

Fair Point, Here is the post I made on the other site:

They basically forgot to refresh the session if the state is "Login Failed" along with "Closed".

If you want to, you can import the facebook sdk into eclipse and change line 63 of FBLogin.Java from

if (SessionState.CLOSED.equals(session.getState())) {
            session = new Builder(FB.getUnityActivity()).setApplicationId(session.getApplicationId()).build();
            Session.setActiveSession(session);
        }

to

   if (SessionState.CLOSED.equals(session.getState()) || SessionState.CLOSED_LOGIN_FAILED.equals(session.getState())) {
                session = new Builder(FB.getUnityActivity()).setApplicationId(session.getApplicationId()).build();
                Session.setActiveSession(session);
            }

Then Export the project as a jar, Only including class files, as classes.jar in the Plugins/Android/facebook/bin folder.

EDIT: It might just be easier if I upload the classes.jar I'm using... Download it here: http://speedy.sh/QPgUp/classes.jar And put it in the Plugins/Android/facebook/bin folder.

EDIT 2: If you are still having this issue, Facebook seems to have released their fix on October 20th 2014. So updating to their newest sdk now fixes the issue!




回答2:


Found an interesting solution for it.

Like I comment in James Baxter's answer, if you call init every time before login, there is no crash even you get the "FB.Init() has already been called. You only need to call this once and only once." error.

But, from the documentation, "This function can only be called once during the lifetime of the object; later calls lead to undefined behavior. ".

The object means the scene? Or another game object?



来源:https://stackoverflow.com/questions/25751057/facebook-unity-sdk-6-0-crash-app-at-second-login

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