Android 上的 Firebase C++ SDK 在创建动态 link 时因 SIGSEGV 错误地址 0x0 而崩溃
Firebase C++ SDK on Android Crashes with SIGSEGV fault addr 0x0 when creating dynamic link
我们在 iOS 和 Android 游戏中使用 Firebase C++ SDK。在 iOS 上,创建动态链接非常完美,但在 Android 上,我们遇到了崩溃,即使经过无数小时的尝试,我们也无法解决这些问题。
这是导致崩溃的代码:
std::string appBundleId = getAppBundleIdentifier();
firebase::dynamic_links::IOSParameters ios_parameters(appBundleId.c_str());
firebase::dynamic_links::AndroidParameters android_parameters(appBundleId.c_str());
firebase::dynamic_links::DynamicLinkComponents components(
"https://example.com/", "abc123.app.goo.gl");
components.android_parameters = &android_parameters;
components.ios_parameters = &ios_parameters;
// This log shows that the app is not nullptr
MLLOG("Firebase Instance %s", firebase::App::GetInstance()->name());
// The next line crashes
firebase::dynamic_links::GeneratedDynamicLink longLink = firebase::dynamic_links::GetLongLink(components);
这是堆栈跟踪,我们通过 adb logcat:
********** Crash dump: **********
Build fingerprint: 'samsung/kccat6xx/kccat6:6.0.1/MMB29M/G901FXXS1CPI4:user/release-keys'
pid: 22798, tid: 23065, name: GLThread 19076 >>> com.forestringgames.apps.towerduel <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Stack frame #00 pc 0416bed4 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN8firebase3App11GetInstanceEPKc+3)
Stack frame #01 pc 041620bf /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN8firebase13dynamic_links11GetLongLinkERKNS0_21DynamicLinkComponentsE+38)
Stack frame #02 pc 0306eb6f /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN15PlatformManager29createDynamicReferralLinkLongEv+226)
Stack frame #03 pc 0260a11f /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #04 pc 0260b307 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #05 pc 041c6df0 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFvPN7cocos2d3RefEEEclES2_+88)
Stack frame #06 pc 0430ce50 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d8MenuItem8activateEv+80)
Stack frame #07 pc 0430d908 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d13MenuItemLabel8activateEv+92)
Stack frame #08 pc 04308df4 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d4Menu12onTouchEndedEPNS_5TouchEPNS_5EventE+196)
Stack frame #09 pc 0430c3f8 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt7_Mem_fnIMN7cocos2d4MenuEFvPNS0_5TouchEPNS0_5EventEEEclIJS3_S5_EvEEvPS1_DpOT_+172)
Stack frame #10 pc 0430c1fc /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt5_BindIFSt7_Mem_fnIMN7cocos2d4MenuEFvPNS1_5TouchEPNS1_5EventEEEPS2_St12_PlaceholderILi1EESB_ILi2EEEE6__callIvJOS4_OS6_EJLj0ELj1ELj2EEEET_OSt5tupleIJDpT0_EESt12_Index_tupleIJXspT1_EEE+200)
Stack frame #11 pc 0430be34 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt5_BindIFSt7_Mem_fnIMN7cocos2d4MenuEFvPNS1_5TouchEPNS1_5EventEEEPS2_St12_PlaceholderILi1EESB_ILi2EEEEclIJS4_S6_EvEET0_DpOT_+104)
Stack frame #12 pc 0430ba68 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt17_Function_handlerIFvPN7cocos2d5TouchEPNS0_5EventEESt5_BindIFSt7_Mem_fnIMNS0_4MenuEFvS2_S4_EEPS8_St12_PlaceholderILi1EESD_ILi2EEEEE9_M_invokeERKSt9_Any_dataS2_S4_+80)
Stack frame #13 pc 025e613d /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFvPN7cocos2d5TouchEPNS0_5EventEEEclES2_S4_+68)
Stack frame #14 pc 043de15c /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #15 pc 043e5a08 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #16 pc 043e1f64 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFbPN7cocos2d13EventListenerEEEclES2_+88)
Stack frame #17 pc 043dd850 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher29dispatchTouchEventToListenersEPNS0_19EventListenerVectorERKSt8functionIFbPNS_13EventListenerEEE+1128)
Stack frame #18 pc 043de8c8 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher18dispatchTouchEventEPNS_10EventTouchE+552)
Stack frame #19 pc 043ddb90 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher13dispatchEventEPNS_5EventE+156)
Stack frame #20 pc 0438dc50 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d6GLView26handleTouchesOfEndOrCancelENS_10EventTouch9EventCodeEiPiPfS4_+732)
Stack frame #21 pc 0438dd88 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d6GLView16handleTouchesEndEiPiPfS2_+60)
Stack frame #22 pc 041469e1 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd+68)
Stack frame #23 pc 01096e41 /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxRenderer.nativeTouchesEnd(int, float, float)+100)
Stack frame #24 pc 010971e3 /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxRenderer.handleActionUp(int, float, float)+70)
Stack frame #25 pc 010841a7 /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxGLSurfaceView.run()+170)
Stack frame #26 pc 03e4cd8d /system/framework/arm/boot.oat (offset 0x2f48000)
以防万一这可能是问题的一部分,我们的 firebase 应用程序似乎已成功创建 - 我们通过 onCreate 的本机调用来完成此操作:
JNIEXPORT void JNICALL Java_org_cocos2dx_cpp_AppActivity_onCreate(JNIEnv* env, jclass, jobject aMainActivity)
{
MLLOG("java_org_cocos2dx_cpp_AppActivity_onCreate called");
firebase::AppOptions appOptions;
_firebaseApp = firebase::App::Create(appOptions, env, aMainActivity);
auto app = firebase::App::GetInstance();
// Both log the same pointer here
MLLOG("FIREBASE APP INIT %p AppGetInstance %p", _firebaseApp, app);
}
您是否尝试过使用
初始化您的应用
::firebase::dynamic_links::Initialize(app, null);
在调用 GetLongLink 之前?
我们在 iOS 和 Android 游戏中使用 Firebase C++ SDK。在 iOS 上,创建动态链接非常完美,但在 Android 上,我们遇到了崩溃,即使经过无数小时的尝试,我们也无法解决这些问题。
这是导致崩溃的代码:
std::string appBundleId = getAppBundleIdentifier();
firebase::dynamic_links::IOSParameters ios_parameters(appBundleId.c_str());
firebase::dynamic_links::AndroidParameters android_parameters(appBundleId.c_str());
firebase::dynamic_links::DynamicLinkComponents components(
"https://example.com/", "abc123.app.goo.gl");
components.android_parameters = &android_parameters;
components.ios_parameters = &ios_parameters;
// This log shows that the app is not nullptr
MLLOG("Firebase Instance %s", firebase::App::GetInstance()->name());
// The next line crashes
firebase::dynamic_links::GeneratedDynamicLink longLink = firebase::dynamic_links::GetLongLink(components);
这是堆栈跟踪,我们通过 adb logcat:
********** Crash dump: **********
Build fingerprint: 'samsung/kccat6xx/kccat6:6.0.1/MMB29M/G901FXXS1CPI4:user/release-keys'
pid: 22798, tid: 23065, name: GLThread 19076 >>> com.forestringgames.apps.towerduel <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Stack frame #00 pc 0416bed4 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN8firebase3App11GetInstanceEPKc+3)
Stack frame #01 pc 041620bf /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN8firebase13dynamic_links11GetLongLinkERKNS0_21DynamicLinkComponentsE+38)
Stack frame #02 pc 0306eb6f /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN15PlatformManager29createDynamicReferralLinkLongEv+226)
Stack frame #03 pc 0260a11f /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #04 pc 0260b307 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #05 pc 041c6df0 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFvPN7cocos2d3RefEEEclES2_+88)
Stack frame #06 pc 0430ce50 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d8MenuItem8activateEv+80)
Stack frame #07 pc 0430d908 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d13MenuItemLabel8activateEv+92)
Stack frame #08 pc 04308df4 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d4Menu12onTouchEndedEPNS_5TouchEPNS_5EventE+196)
Stack frame #09 pc 0430c3f8 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt7_Mem_fnIMN7cocos2d4MenuEFvPNS0_5TouchEPNS0_5EventEEEclIJS3_S5_EvEEvPS1_DpOT_+172)
Stack frame #10 pc 0430c1fc /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt5_BindIFSt7_Mem_fnIMN7cocos2d4MenuEFvPNS1_5TouchEPNS1_5EventEEEPS2_St12_PlaceholderILi1EESB_ILi2EEEE6__callIvJOS4_OS6_EJLj0ELj1ELj2EEEET_OSt5tupleIJDpT0_EESt12_Index_tupleIJXspT1_EEE+200)
Stack frame #11 pc 0430be34 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt5_BindIFSt7_Mem_fnIMN7cocos2d4MenuEFvPNS1_5TouchEPNS1_5EventEEEPS2_St12_PlaceholderILi1EESB_ILi2EEEEclIJS4_S6_EvEET0_DpOT_+104)
Stack frame #12 pc 0430ba68 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt17_Function_handlerIFvPN7cocos2d5TouchEPNS0_5EventEESt5_BindIFSt7_Mem_fnIMNS0_4MenuEFvS2_S4_EEPS8_St12_PlaceholderILi1EESD_ILi2EEEEE9_M_invokeERKSt9_Any_dataS2_S4_+80)
Stack frame #13 pc 025e613d /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFvPN7cocos2d5TouchEPNS0_5EventEEEclES2_S4_+68)
Stack frame #14 pc 043de15c /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #15 pc 043e5a08 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #16 pc 043e1f64 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFbPN7cocos2d13EventListenerEEEclES2_+88)
Stack frame #17 pc 043dd850 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher29dispatchTouchEventToListenersEPNS0_19EventListenerVectorERKSt8functionIFbPNS_13EventListenerEEE+1128)
Stack frame #18 pc 043de8c8 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher18dispatchTouchEventEPNS_10EventTouchE+552)
Stack frame #19 pc 043ddb90 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher13dispatchEventEPNS_5EventE+156)
Stack frame #20 pc 0438dc50 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d6GLView26handleTouchesOfEndOrCancelENS_10EventTouch9EventCodeEiPiPfS4_+732)
Stack frame #21 pc 0438dd88 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d6GLView16handleTouchesEndEiPiPfS2_+60)
Stack frame #22 pc 041469e1 /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd+68)
Stack frame #23 pc 01096e41 /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxRenderer.nativeTouchesEnd(int, float, float)+100)
Stack frame #24 pc 010971e3 /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxRenderer.handleActionUp(int, float, float)+70)
Stack frame #25 pc 010841a7 /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxGLSurfaceView.run()+170)
Stack frame #26 pc 03e4cd8d /system/framework/arm/boot.oat (offset 0x2f48000)
以防万一这可能是问题的一部分,我们的 firebase 应用程序似乎已成功创建 - 我们通过 onCreate 的本机调用来完成此操作:
JNIEXPORT void JNICALL Java_org_cocos2dx_cpp_AppActivity_onCreate(JNIEnv* env, jclass, jobject aMainActivity)
{
MLLOG("java_org_cocos2dx_cpp_AppActivity_onCreate called");
firebase::AppOptions appOptions;
_firebaseApp = firebase::App::Create(appOptions, env, aMainActivity);
auto app = firebase::App::GetInstance();
// Both log the same pointer here
MLLOG("FIREBASE APP INIT %p AppGetInstance %p", _firebaseApp, app);
}
您是否尝试过使用
初始化您的应用::firebase::dynamic_links::Initialize(app, null);
在调用 GetLongLink 之前?