Facebook Unity Sdk v5.0.3 crashes in Landscape mod

2019-02-19 20:10发布

问题:

The game crashes when I click at login button as the game is in landscape mode. If I use portrait mode, everything works fine and correctly.

I got the following stack trace from bugsense when I got the crash.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.adssdk.plugins/com.facebook.unity.FBUnityLoginActivity}: java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.
1at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
2at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2240)
3at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3809)
4at android.app.ActivityThread.access$700(ActivityThread.java:139)
5at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1266)
6at android.os.Handler.dispatchMessage(Handler.java:99)
7at android.os.Looper.loop(Looper.java:156)
8at android.app.ActivityThread.main(ActivityThread.java:4987)
9at java.lang.reflect.Method.invokeNative(Native Method)
10at java.lang.reflect.Method.invoke(Method.java:511)
11at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
13at dalvik.system.NativeStart.main(Native Method)
14Caused by: java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.
15at com.facebook.Session.requestNewPermissions(Session.java:1006)
16at com.facebook.Session.requestNewPublishPermissions(Session.java:512)
17at com.facebook.unity.FB.initAndLogin(FB.java:200)
18at com.facebook.unity.FB.LoginUsingActivity(FB.java:249)
19at com.facebook.unity.FBUnityLoginActivity.onCreate(FBUnityLoginActivity.java:13)
20at android.app.Activity.performCreate(Activity.java:4538)
21at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
22at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)

If anyone of you has implemented this in landscape mode and is not getting a crash while logging in, do let me know.

回答1:

yes, this is a bug, we are working on proper fix right now. Meanwhile you can edit your android manifest in Plugins/Android and add android:configChanges so that FBUnityLoginActivity isn't destroyed when orientation/whatever changes:

<activity 
  android:name="com.facebook.unity.FBUnityLoginActivity" 
  android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
  android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
</activity>

you may also want to remove "Translucent" from activity style.



回答2:

I confirm that the change in the manifest file fixed the crash for me also. As additional info: the location of manifest the file was in Assets\Plugins\Android and the name was AndroidManifest.xml. I tested the fix on Sony Xperia M.