- Home /
Facebook sdk cancelled login crash
Hi
I'm trying to implement the facebook sdk in my game (android, iOS). Login works, all the api calls work, but I get a crash, in the following case:
press login
facebook login page or if installed, the facebook app comes up properly
cancel login
goes back to the app properly
press login again, and it will crash
07-08 14:39:11.172: E/AndroidRuntime(23699): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage/com.facebook.unity.FBUnityLoginActivity}: java.lang.UnsupportedOperationException: Session: an attempt was made to open an already opened session.
I've tried to call logout(which would clear the session) before calling login again, but that did not help.
Any ideas how to fix this?
I'm having this issue right now on android with facebook unity sdk 6.0 August 11, 2014. Anyone?
Ah. Got it: https://developers.facebook.com/bugs/791682207518626/
Ibrahim Faour · Facebook Platform Team: A fix for this issue will be included in the next version of the SD$$anonymous$$ which we will be releasing shortly. August 25 at 1:57pm. How short is "shortly", I wonder...
Answer by Helath · Oct 14, 2014 at 03:31 PM
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.
Answer by LeonardK · Mar 12, 2015 at 07:31 PM
It is also nice idea not to compare java strings using == operator. where appID compared with session.getApplicationId()