【问题标题】:App does not build after upgrading to 3.0.0升级到 3.0.0 后应用程序无法构建
【发布时间】:2022-06-15 15:13:57
【问题描述】:

在将 Flutter 升级到新的 3.0.0 后,qr_code_scanner 库出现问题

e: /home/kalheeso/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/qr_code_scanner-0.7.0/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt: (23, 1): Class 'QRView' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
e: /home/kalheeso/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/qr_code_scanner-0.7.0/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt: (216, 26): Null can not be a value of a non-null type String
e: /home/kalheeso/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/qr_code_scanner-0.7.0/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt: (247, 26): Null can not be a value of a non-null type String
e: /home/kalheeso/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/qr_code_scanner-0.7.0/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt: (310, 5): 'onRequestPermissionsResult' overrides nothing
e: /home/kalheeso/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/qr_code_scanner-0.7.0/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRViewFactory.kt: (10, 1): Class 'QRViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
e: /home/kalheeso/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/qr_code_scanner-0.7.0/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRViewFactory.kt: (13, 5): 'create' overrides nothing

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':qr_code_scanner:compileDebugKotlin'.
> Compilation error. See log for more details

【问题讨论】:

    标签: android flutter flutter-dependencies


    【解决方案1】:

    使用替代mobile_scanner。这个库在 Flutter 3.0 中不起作用。要不然 如果你想使用 qr_code_scanner 库,那不是官方的 creator repo,但你可以使用它。

    dependency_overrides:
        qr_code_scanner:
            git:
                url: https://github.com/X-SLAYER/qr_code_scanner.git
                ref: flutter-beta
    

    【讨论】:

    • 谢谢。你认为他们很快就会增加对 3.0 版本的支持吗?上一个版本发布已经 3 个月了,但它仍然是 pub.dev 中我所见过的最流行的二维码库
    • @MatheusMelo 如果你想使用 qr_code_scanner 添加这个到 pubspec.yaml 依赖覆盖:qr_code_scanner: git: url: github.com/X-SLAYER/qr_code_scanner.git ref: flutter-beta
    【解决方案2】:

    我不同意所选答案。 qr_code_scanner 库与 Flutter 3.0.1 兼容。

    1. qr_code_scanner 库升级到1.0.0
    2. flutter升级为3.0.1

    现在您可以将qr_code_scannerflutter 3.x 一起使用,无需更改整个二维码库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-09
      • 2016-02-20
      • 1970-01-01
      • 2021-04-02
      • 2022-08-11
      • 1970-01-01
      • 1970-01-01
      • 2021-11-28
      相关资源
      最近更新 更多