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?

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: Loading...
And put it in the Plugins/Android/facebook/bin folder.

Thanks for the classes.jar - it solves the problem!

It is also nice idea not to compare java strings using == operator.
where appID compared with session.getApplicationId()