uni-app 新建uts插件引入巨量归因BDASignalSDK依赖Protobuf打包后调用sdk方法闪退 日志如下

发布于 1周前 作者 nodeper 来自 Uni-App

uni-app 新建uts插件引入巨量归因BDASignalSDK依赖Protobuf打包后调用sdk方法闪退 日志如下

开发环境 版本号 项目创建方式
Mac macOs Monterey 12.6 -

操作步骤:

import "BDASignalSDK"  
export function initJl():void{  
    let data: Map<string,any> = new Map()  
    data.set("user_unique_id","1234566")  
    BDASignalSDK.BDASignalManager.register(withOptionalData = data)  
}
{
    "deploymentTarget": "11.0",   // 可选,插件支持的最低 iOS 版本  默认:9.0"
    "dependencies-pods": [ // 可选, 需要依赖的 CocoaPods 库, HBuilderX 3.8.5+ 版本支持  
    {  
        "name": "BDASignalSDK",  
        "repo": {  
         "git": "https://github.com/oceanengine/bda_signal_sdk.git" //指定 pod 库的仓库地址  
        }  
    },  
    {  
        "name": "Protobuf",  
        "version": "3.25.1"  
    }  
    ]  
}

预期结果:

  • 正常调用

实际结果:

  • app闪退

bug描述:

新建一个uts插件 引入巨量归因BDASignalSDK,它依赖Protobuf打包之后,调用sdk的方法闪退,日志如下

-------------------------------------    
Translated Report (Full Report Below)    
-------------------------------------    

Incident Identifier: ADAFFE5E-36E1-4B72-8EBB-8673C6E07018    
CrashReporter Key:   C2315A0A-767E-DD9D-D816-AE46F847627B    
Hardware Model:      MacBookPro16,1    
Process:             HBuilder [12219]    
Path:                /Users/USER/Library/Developer/CoreSimulator/Devices/9915CB8B-45D0-43A8-ACF7-2794E8A18ED6/data/Containers/Bundle/Application/F6E729A9-3162-4717-9E2B-E2E4A02A7408/Pandora_simulator_debug.app/HBuilder    
Identifier:          com.zhengda.qpzjz.ios    
Version:             1.1.0 (110)    
Code Type:           X86-64 (Native)    
Role:                Foreground    
Parent Process:      launchd_sim [12062]    
Coalition:           com.apple.CoreSimulator.SimDevice.9915CB8B-45D0-43A8-ACF7-2794E8A18ED6 [8670]    
Responsible Process: SimulatorTrampoline [952]    

Date/Time:           2023-12-23 15:21:02.1636  0800    
Launch Time:         2023-12-23 15:20:28.7712  0800    
OS Version:          macOS 14.1.2 (23B92)    
Release Type:        User    
Report Version:      104    

Exception Type:  EXC_BREAKPOINT (SIGTRAP)    
Exception Codes: 0x0000000000000002, 0x0000000000000000    
Triggered by Thread:  5    

Thread 0::  Dispatch queue: com.apple.main-thread    
0   libsystem_kernel.dylib                    0x7ff836116a6e mach_msg2_trap   10    
1   libsystem_kernel.dylib                    0x7ff836124e7a mach_msg2_internal   84    
2   libsystem_kernel.dylib                    0x7ff83611db92 mach_msg_overwrite   653    
3   libsystem_kernel.dylib                    0x7ff836116d5f mach_msg   19    
4   CoreFoundation                            0x7ff80038788e __CFRunLoopServiceMachPort   145    
5   CoreFoundation                            0x7ff800381fdf __CFRunLoopRun   1371    
6   CoreFoundation                            0x7ff8003816a7 CFRunLoopRunSpecific   560    
7   GraphicsServices                          0x7ff809cb128a GSEventRunModal   139    
8   UIKitCore                                    0x110204ad3 -[UIApplication _run]   994    
9   UIKitCore                                    0x1102099ef UIApplicationMain   123    
10  HBuilder                                     0x1009559c3 main   99    
11  dyld_sim                                     0x1015032bf start_sim   10    
12  dyld                                         0x1036413a6 start   1942    

Thread 1:    
0   libsystem_pthread.dylib                   0x7ff836172b88 start_wqthread   0    

Thread 2::  Dispatch queue: com.apple.CFNetwork.Connection    
0   libcorecrypto.dylib                       0x7ff800206870 AccelerateCrypto_AES_encrypt_aesni   0    
1   libcorecrypto.dylib                       0x7ff8001fe820 ecb_wrapper_aesni   58    
2   libcorecrypto.dylib                       0x7ff8001d8eff ccaes_vng_ctr_crypt   193    
3   libcorecrypto.dylib                       0x7ff8001de8bb generate   383    
4   libcorecrypto.dylib                       0x7ff8001df16d ccrng_crypto_generate   287    
5   libcorecrypto.dylib                       0x7ff8001c2ddc generate   17    
6   libsystem_c.dylib                         0x7ff8000c5ea8 uuid_generate_random   61    
7   Network                                   0x7ff805807faa -[NWConcrete_nw_connection initWithEndpoint:parameters:identifier:]   474    
8   Network                                   0x7ff80581eac5 nw_connection_create_with_id   197    
9   Network                                   0x7ff805811063 nw_connection_create   83    
10  CFNetwork                                 0x7ff804284d08 0x7ff8041df000   679176    
11  CFNetwork                                 0x7ff804300b51 0x7ff8041df000   1186641    
12  CFNetwork                                 0x7ff80427786a 0x7ff8041df000   624746    
13  CFNetwork                                 0x7ff8042ffd8c 0x7ff8041df000   1183116    
14  CFNetwork                                 0x7ff8043037c1 0x7ff8041df000   1198017    
15  CFNetwork                                 0x7ff804303a4a 0x7ff8041df000   1198666    
16  libdispatch.dylib                         0x7ff80013b7fb _dispatch_call_block_and_release   12    
17  libdispatch.dylib                         0x7ff80013ca3a _dispatch_client_callout   8    
18  libdispatch.dylib                         0x7ff800144346 _dispatch_lane_serial_drain   949    
19  libdispatch.dylib                         0x7ff80014501a _dispatch_lane_invoke   455    
20  libdispatch.dylib                         0x7ff80014658c _dispatch_workloop_invoke   2447    
21  libdispatch.dylib                         0x7ff800151b46 _dispatch_workloop_worker_thread   870    
22  libsystem_pthread.dylib                   0x7ff836173c47 _pthread_wqthread   327    
23  libsystem_pthread.dylib                   0x7ff836172b97 start_wqthread   15    

Thread 3:: com.apple.uikit.eventfetch-thread    
0   libsystem_kernel.dylib                    0x7ff836116a6e mach_msg2_trap   10    
1   libsystem_kernel.dylib                    0x7ff836124e7a mach_msg2_internal   84    
2   libsystem_kernel.dylib                    0x7ff83611db92 mach_msg_overwrite   653    
3   libsystem_kernel.dylib                    0x7ff836116d5f mach_msg   19    
4   CoreFoundation                            0x7ff80038788e __CFRunLoopServiceMachPort   145    
5   CoreFoundation                            0x7ff800381fdf __CFRunLoopRun   1371    
6   CoreFoundation                            0x7ff8003816a7 CFRunLoopRunSpecific   560    
7   Foundation                                0x7ff800c568b4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]   213    
8   Foundation                                0x7ff800c56b2d -[NSRunLoop(NSRunLoop) runUntilDate:]   72    
9   UIKitCore                                    0x1102da286 -[UIEventFetcher threadMain]   535    
10  Foundation                                0x7ff800c8011b __NSThread__start__   1009    
11  libsystem_pthread.dylib                   0x7ff836177202 _pthread_start   99    
12  libsystem_pthread.dylib                   0x7ff836172bab thread_start   15    

Thread 4:    
0   libsystem_pthread.dylib                   0x7ff836172b88 start_wqthread   0    

Thread 5 Crashed:: com.taobao.weex.bridge    
0   WebKit                                       0x107a7bfb3 WTFCrashWithInfo(int, char const*, char const*, int)   19    
1   WebKit                                       0x107e41da5 WebKit::captivePortalModeObservers()   60    
2   WebKit                                       0x107e42041 WebKit::addCaptivePortalModeObserver(WebKit::CaptivePortalModeObserver

2 回复

根据你提供的信息,问题可能出现在以下几个方面:

  1. 依赖冲突BDASignalSDK 可能依赖了特定版本的 Protobuf,而你的项目中可能已经存在其他版本的 Protobuf,导致冲突。

  2. Native 代码问题BDASignalSDK 可能包含了一些 Native 代码(如 C++ 或 Objective-C),这些代码在打包时可能没有正确编译或链接,导致运行时崩溃。

  3. 权限或配置问题BDASignalSDK 可能需要某些特定的权限或配置,如果这些没有正确设置,可能会导致应用崩溃。

  4. 日志分析:你提供的日志信息不完整,但通常可以从日志中找到崩溃的具体原因。常见的日志关键字包括 NullPointerExceptionClassNotFoundExceptionUnsatisfiedLinkError 等。

解决步骤

  1. 检查依赖冲突

    • 确保 BDASignalSDKProtobuf 的版本兼容。
    • 使用 ./gradlew dependencies 检查依赖树,查看是否有冲突的依赖。
  2. 检查 Native 代码

    • 确保 BDASignalSDK 的 Native 代码正确编译和链接。
    • 检查 CMakeLists.txtAndroid.mk 文件,确保所有必要的库都正确包含。
  3. 检查权限和配置

    • 确保 AndroidManifest.xml 中包含了 BDASignalSDK 所需的所有权限。
    • 检查 BDASignalSDK 的初始化代码,确保所有必要的配置都已正确设置。
  4. 分析日志

    • 查看完整的日志信息,找到崩溃的具体原因。
    • 如果日志中有 UnsatisfiedLinkError,可能是 Native 库没有正确加载。
    • 如果日志中有 NullPointerException,可能是某些对象没有正确初始化。

示例代码

假设你正在使用 uni-apputs 插件来引入 BDASignalSDK,以下是一个简单的示例代码:

// 引入 BDASignalSDK
const BDASignalSDK = require('BDASignalSDK');

// 初始化 SDK
BDASignalSDK.init({
  appId: 'your_app_id',
  appKey: 'your_app_key'
});

// 调用 SDK 方法
BDASignalSDK.trackEvent('event_name', { key: 'value' });

日志分析示例

假设日志中有以下内容:

java.lang.UnsatisfiedLinkError: No implementation found for void com.bda.signal.SignalSDK.init(java.lang.String, java.lang.String) (tried Java_com_bda_signal_SignalSDK_init and Java_com_bda_signal_SignalSDK_init__Ljava_lang_String_2Ljava_lang_String_2)
回到顶部
AI 助手
你好,我是IT营的 AI 助手
您可以尝试点击下方的快捷入口开启体验!