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

如何解决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.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?