Facebook登录时cocos2dx android崩溃

时间:2013-11-18 03:34:15

标签: android facebook android-ndk cocos2d-x facebook-android-sdk

我在我的cocos2d-x-2.2 app上集成了Facebook SDK for Android

我按照FacebookSDK文档中的说明调用登录功能,我还将Cocos2dxGameActivity更改为singleInstance以支持SSO。我的登录功能如下:

    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");
            }
        });
    }
}

但是,在openActiveSession调用时,应用程序始终在本机代码中因以下空指针异常而崩溃:

11-18 11:13:37.981:E / cocos2d-x断言(6973):C:/cocos2d-x-2.2/projects/fb-test/proj.android /../../../ cocos2dx / platform / android / CCApplication.cpp函数:sharedApplication line:60 11-18 11:13:37.981:A / libc(6973):致命信号11(SIGSEGV)位于0x00000000(代码= 1),线程6994(Thread-16380)

以前有人遇到过这个吗?

感谢您的投入!

1 个答案:

答案 0 :(得分:8)

Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause()中存在错误 在调用applicationDidEnterBackground();

之前,它没有检查NULL

添加:

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

你应该安全......

退房:

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