Flutter iOS应用Thread 35崩溃,请求协助排查故障原因
Flutter iOS应用崩溃定位求助
我的Flutter iOS应用发生崩溃,无法定位问题所在。报错显示Thread 35崩溃,相关信息如下:
Thread 35 Crashed:: Dispatch queue: com.apple.root.default-qos 0 libsystem_kernel.dylib 0x7ff83611d00e __pthread_kill + 10 1 libsystem_pthread.dylib 0x7ff8361741ff pthread_kill + 263 2 libsystem_c.dylib 0x7ff800132fe0 abort + 130 3 libc++abi.dylib 0x7ff800258742 abort_message + 241 4 libc++abi.dylib 0x7ff80024995d demangling_terminate_handler() + 266 5 libobjc.A.dylib 0x7ff800032082 _objc_terminate() + 96 6 libc++abi.dylib 0x7ff800257b65 std::__terminate(void (*)()) + 8 7 libc++abi.dylib 0x7ff800257b16 std::terminate() + 54 8 libdispatch.dylib 0x7ff80013ca4e _dispatch_client_callout + 28 9 libdispatch.dylib 0x7ff80013f91a _dispatch_queue_override_invoke + 1278 10 libdispatch.dylib 0x7ff80014fdf7 _dispatch_root_queue_drain + 414 11 libdispatch.dylib 0x7ff800150928 _dispatch_worker_thread2 + 251 12 libsystem_pthread.dylib 0x7ff836170f8a _pthread_wqthread + 256 13 libsystem_pthread.dylib 0x7ff83616ff57 start_wqthread + 15
不清楚该如何调查此问题,希望能得到帮助。
完整崩溃报告如下(完整版无法在SO中展示):
------------------------------------- Translated Report (Full Report Below) ------------------------------------- Incident Identifier: 6829AC69-7A83-4B4F-BBE5-20DECC8A7B41 CrashReporter Key: 72ECC7F9-A13D-0779-EBFB-B8D97FE278A4 Hardware Model: MacBookPro16,1 Process: Runner [89254] Path: /Users/USER/Library/Developer/CoreSimulator/Devices/D4B84C45-D13B-48C4-8A91-0C3B440E6CA1/data/Containers/Bundle/Application/700BCE47-B980-46D2-8DDD-0216964BE516/Runner.app/Runner Identifier: com.shokaze.shokaze Version: 1.0.0 (33) Code Type: X86-64 (Native) Role: Foreground Parent Process: launchd_sim [68205] Coalition: com.apple.CoreSimulator.SimDevice.D4B84C45-D13B-48C4-8A91-0C3B440E6CA1 [12917] Responsible Process: SimulatorTrampoline [1187] Date/Time: 2023-04-18 00:32:09.5771 +0200 Launch Time: 2023-04-18 00:32:06.3918 +0200 OS Version: macOS 12.6.2 (21G320) Release Type: User Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 35 Last Exception Backtrace: 0 CoreFoundation 0x7ff80042889b __exceptionPreprocess + 226 1 libobjc.A.dylib 0x7ff80004dba3 objc_exception_throw + 48 2 CoreFoundation 0x7ff80042851d -[NSException init] + 0 3 Runner 0x109f8f35c GADApplicationVerifyPublisherInitializedCorrectly + 380 4 Runner 0x109f8f512 0x10973c000 + 8729874 5 libdispatch.dylib 0x7ff80013b7fb _dispatch_call_block_and_release + 12 6 libdispatch.dylib 0x7ff80013ca3a _dispatch_client_callout + 8 7 libdispatch.dylib 0x7ff80013f91a _dispatch_queue_override_invoke + 1278 8 libdispatch.dylib 0x7ff80014fdf7 _dispatch_root_queue_drain + 414 9 libdispatch.dylib 0x7ff800150928 _dispatch_worker_thread2 + 251 10 libsystem_pthread.dylib 0x7ff836170f8a _pthread_wqthread + 256 11 libsystem_pthread.dylib 0x7ff83616ff57 start_wqthread + 15 Thread 0:: Dispatch queue: com.apple.main-thread 0 Runner 0x109f6364e 0x10973c000 + 8549966 1 Runner 0x109f9011c 0x10973c000 + 8732956 2 libdispatch.dylib 0x7ff80013b7fb _dispatch_call_block_and_release + 12 3 libdispatch.dylib 0x7ff80013ca3a _dispatch_client_callout + 8 4 libdispatch.dylib 0x7ff80014c32c _dispatch_main_queue_drain + 1338 5 libdispatch.dylib 0x7ff80014bde4 _dispatch_main_queue_callback_4CF + 31 6 CoreFoundation 0x7ff800387b1f __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 7 CoreFoundation 0x7ff800382436 __CFRunLoopRun + 2482 8 CoreFoundation 0x7ff8003816a7 CFRunLoopRunSpecific + 560 9 GraphicsServices 0x7ff809cb128a GSEventRunModal + 139 10 UIKitCore 0x1283e0ad3 -[UIApplication _run] + 994 11 UIKitCore 0x1283e59ef UIApplicationMain + 123 12 Runner 0x10974429f main + 63 (AppDelegate.swift:5) 13 dyld_sim 0x10b0e22bf start_sim + 10 14 dyld 0x114ed552e start + 462
问题定位与解决
从崩溃日志的Last Exception Backtrace中能看到关键线索:GADApplicationVerifyPublisherInitializedCorrectly,这是Google Ads SDK的校验方法,说明崩溃是因Google Ads SDK初始化不正确导致的。
具体排查步骤:
- 检查Google Ads SDK初始化时机:必须在应用启动阶段(比如
main函数或AppDelegate的didFinishLaunchingWithOptions方法)调用GADMobileAds.sharedInstance().start(completionHandler: nil),且要在使用任何广告相关API前完成初始化。 - 确认
Info.plist配置:添加GADApplicationIdentifier键,值为你的AdMob应用ID,确保配置正确。 - 验证插件版本兼容性:如果你使用的是Flutter的
google_mobile_ads插件,确保插件版本与原生Google Ads SDK兼容,建议更新到最新稳定版。 - 检查初始化线程:必须在主线程初始化广告SDK,避免在后台线程或延迟初始化。
如果以上步骤无效,可尝试:
- 清理项目缓存:执行
flutter clean后重新编译运行。 - 重置测试环境:删除当前模拟器,新建模拟器测试。
- 排查插件冲突:暂时禁用其他第三方插件,逐步排查是否存在冲突。
内容的提问来源于stack exchange,提问作者Stéphane de Luca
相关产品推荐
相关产品推荐

