Flutter 地理围栏在真实设备上运行时崩溃

问题描述

我正在开发使用 Geofencing 插件Flutter 应用程序。当我在 iOS 模拟器中运行该应用程序时,它运行良好,但是当我尝试在我的手机上运行它时,该应用程序在启动时崩溃:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Region Info: 0 is not in any region.  Bytes before following region: 4300980224
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                   1005bc000-100a88000 [ 4912K] r-x/r-x SM=COW  ...er.app/Runner

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL,Code 0xb
Terminating Process: exc handler [27910]
Triggered by Thread:  0

Thread 0 name:  dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libswiftCore.dylib              0x000000019ca7e6e4 swift_getobjectType + 40
1   Runner                          0x00000001005c3630 @objc AppDelegate.registerPlugins(inRegistry:) + 30256 (<compiler-generated>:38)
2   Runner                          0x00000001005c3630 @objc AppDelegate.registerPlugins(inRegistry:) + 30256 (<compiler-generated>:38)
3   geofencing                      0x0000000100ff9a14 -[GeofencingPlugin startGeofencingService:] + 23060 (GeofencingPlugin.m:178)
4   geofencing                      0x0000000100ff8dec -[GeofencingPlugin handleMethodCall:result:] + 19948 (GeofencingPlugin.m:49)
5   Flutter                         0x0000000101912804 0x101380000 + 5842948
6   Flutter                         0x00000001013b330c 0x101380000 + 209676
7   Flutter                         0x00000001016ab908 0x101380000 + 3324168
8   Flutter                         0x000000010164ca10 0x101380000 + 2935312
9   Flutter                         0x000000010164e870 0x101380000 + 2943088
10  CoreFoundation                  0x0000000198a45fa0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
11  CoreFoundation                  0x0000000198a45ba0 __CFRunLoopDoTimer + 1064
12  CoreFoundation                  0x0000000198a44ffc __CFRunLoopDoTimers + 328
13  CoreFoundation                  0x0000000198a3eee4 __CFRunLoopRun + 1936
14  CoreFoundation                  0x0000000198a3e21c CFRunLoopRunSpecific + 600
15  GraphicsServices                0x00000001b0bf0784 GSEventRunModal + 164
16  UIKitCore                       0x000000019b47ff58 -[UIApplication _run] + 1072
17  UIKitCore                       0x000000019b4857cc UIApplicationMain + 168
18  Runner                          0x00000001005c3718 main + 30488 (AppDelegate.swift:9)
19  libdyld.dylib                   0x00000001986fe6b0 start + 4

我的 AppDelegate.swift 文件如下所示:

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    override func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {

        // Register plugins which talk to Dart and Flutter.
        registerPlugins(inRegistry: self)

        // 2020-11 DC - My understanding here is that we need to pass the geofencing plugin a method call so that when it's called in the background,// it can initialize all the plugins which will not have been regsitered because the app has not been started.
        // The intent is to ensure that other plugins get initialized so the geofencing plugin can send messages through to the Flutter app.
        // However because this version of the plugin was written in Objective-C it expects a C convention callback which Swift does not handle directly.
        // Hence we have to use this code which takes a swift selector and converts it to a C functioon pointer which we can give the the plugin.
        let selector = #selector(registerPlugins(inRegistry:))
        let signature = (@convention(c) (FlutterPluginRegistry) -> Void).self
        let method = unsafeBitCast(self.method(for: selector),to: signature)
        GeofencingPlugin.setPluginRegistrantCallback(method)

        return super.application(application,didFinishLaunchingWithOptions: launchOptions)
    }

    @objc
    func registerPlugins(inRegistry registry: FlutterPluginRegistry) {
        os_log("? AppDelegate: Registering plugins ...",type: .debug)
        GeneratedpluginRegistrant.register(with: registry)
    }
}

我不知道问题出在哪里。堆栈跟踪似乎表明正在调用回调,因此我认为它必须已正确注册

有什么想法可能出问题了吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...