创建动态链接时,Android 上的 Firebase C++ SDK 因 SIGSEGV 故障地址 0x0 而崩溃

Posted

技术标签:

【中文标题】创建动态链接时,Android 上的 Firebase C++ SDK 因 SIGSEGV 故障地址 0x0 而崩溃【英文标题】:Firebase C++ SDK on Android Crashes with SIGSEGV fault addr 0x0 when creating dynamic link 【发布时间】:2017-10-11 14:09:46 【问题描述】:

我们正在为我们的 iosandroid 游戏使用 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 (_ZNKSt8functionIF***7cocos2d3RefEEEclES2_+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_fnIMN7cocos2d4MenuEF***S0_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_fnIMN7cocos2d4MenuEF***S1_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_fnIMN7cocos2d4MenuEF***S1_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_handlerIF***7cocos2d5TouchEPNS0_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 (_ZNKSt8functionIF***7cocos2d5TouchEPNS0_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$10.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);

【问题讨论】:

【参考方案1】:

您是否尝试过使用初始化您的应用程序

::firebase::dynamic_links::Initialize(app, null);

在调用 GetLongLink 之前?

【讨论】:

以上是关于创建动态链接时,Android 上的 Firebase C++ SDK 因 SIGSEGV 故障地址 0x0 而崩溃的主要内容,如果未能解决你的问题,请参考以下文章

我无法检索应在 Android 上的意图数据内的 Firebase 动态链接

Android - Google + 上的 Firebase 动态社交元标记链接

错误:400:您的项目不拥有动态链接域

Firebase 动态链接没有与自定义标签上的短 URL 进行深度链接

如何创建一个 Firebase 动态链接,点击后会打开一个 android 即时应用程序?

如何为Android,Mac和Windows平台创建Java JNI动态链接库