Question

I am integrating Facebook SDK for Android on my cocos2d-x-2.2 app

I call the login function like instructed in the FacebookSDK documentation, I also changed the Cocos2dxGameActivity to singleInstance to support SSO. My login function is as follows:

    public void loginToFacebook() {
    JLogger.e(null, "MatchThree.loginToFacebook 0");
    if ( Session.getActiveSession() == null || (!Session.getActiveSession().isOpened()) ) {
        Session.openActiveSession(this, true, new Session.StatusCallback() {

            @Override
            public void call(Session session, SessionState state, Exception exception) {
                //
                JLogger.e("Facebook", "loginToFacebook call");
            }
        });
    }
}

However, upon the openActiveSession call, the application always crash with the following null pointer exception in native code:

11-18 11:13:37.981: E/cocos2d-x assert(6973): C:/cocos2d-x-2.2/projects/fb-test/proj.android/../../../cocos2dx/platform/android/CCApplication.cpp function:sharedApplication line:60 11-18 11:13:37.981: A/libc(6973): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 6994 (Thread-16380)

Does anybody encounter this before?

Thanks for your input!

Was it helpful?

Solution

There is a bug in Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() whereby it did not check for NULL before calling applicationDidEnterBackground();

add this:

    if (CCDirector::sharedDirector()->getOpenGLView()) {
        CCApplication::sharedApplication()->applicationDidEnterBackground();
    }

and you should be safe...

Check out:

http://www.cocos2d-x.org/forums/6/topics/33956

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top