The problem
The first time I call FB.Login I'm redirected to facebook but then there seems to be a problem with coming back to my app. I'm getting the message "[App name] has stopped working." I've posted a screenshot of the stacktrace further down.
If I after that crash open my game I can see that I am logged in and can do what I want (Invite friends etc.). But if I log out and then in again, the same problem occurs.
Additional info
Suspicion
Of course I googled the stack trace, and it seems there's a similar problem here and here . From the SDK for Unity release notes, I noticed that even the latest version of the sdk uses Facebook for Android SDK 3.5.0, which points towards the same issue as the question I linked to. If that is indeed the case, is it possible for me to swap the underlying facebook for android sdk in the facebook for unity sdk and update it to a newer version myself?
Stacktrace
I found a solution. I don't understand it at all, but it works. Looking at the stacktrace it seems android can't resume the login activity. I tried running the example project and everything worked, as long as I was running in portrait mode . When I tilted my phone to landscape mode the same crash happened - even in the example scene. Looking at the LoginActivity in the manifest it looked like this:
<activity android:name="com.facebook.LoginActivity" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation">
</activity>
Notice that the screenOrientation is set to portrait. It seems that this, in combination with the fact that my games orientation is set to sensorLandscape - android couldn't find the LoginActivity and thus crashing. I removed the android:screenOrientation="portrait" and everything works.
I am not sure about Unity but basically this problem occurs when the calling activity is not live or destroyed. In android the method onActivityResult() is called after login. The Activity is destroyed forcefully by the mobile( Don't keep activities option enables in the developers options settings). Please Once cross check in the developers options setting that the Don't keep activities is enabled or disabled.
The main problem is the key hash that generate unity. The key which shows unity is different you have to put in facebook settings.
Here's the solution!
That Key BASE64 is the REAL key you have to put in facebook settings on https://apps.facebook.com/nameapp
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.