flutter - 尝试在 android studio 中构建 flutter 项目时出现错误

当我尝试运行我的 flutter 应用程序时,我收到以下错误。可能是什么原因? ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ……

我正在使用 qr_code_scanner: ^0.5.2

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Parameter format not correct -
e: C:\src\flutter\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: C:\src\flutter\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: C:\src\flutter\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: C:\src\flutter\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: C:\src\flutter\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: C:\src\flutter\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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 51s
Exception: Gradle task assembleDebug failed with exit code 1

我的 pubspec.yaml

name: StarMe
description: A Social Media Project.
publish_to: "none"
version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.3
  google_fonts: ^2.1.0
  flutter_icons_nullsafty: ^1.0.0
  http: ^0.13.3
  cached_network_image: ^3.1.0
  encrypt: ^5.0.1
  flutter_svg: ^0.22.0
  qr_flutter: ^4.0.0
  clipboard: ^0.1.3
  share: ^2.0.4
  qr_code_scanner: ^0.7.0
  fluro: ^2.0.3
  url_launcher: ^6.0.10
  image_picker: ^0.8.4
  country_code_picker: ^2.0.2
  introduction_screen: ^2.1.0
  pin_code_fields: ^7.3.0
  provider: ^6.0.0
  hive: ^2.0.4
  hive_flutter: ^1.1.0
  flutter_secure_storage: ^4.2.1
  local_auth: ^1.1.7
  permission_handler: ^8.1.4+2
  fl_chart: ^0.40.0
  carousel_slider: ^4.0.0
  web3dart: ^2.3.1
  device_info_plus: ^2.1.0
  package_info_plus: ^1.3.0
  intl: ^0.17.0
  flutter_paystack:
    git:
      url: https://github.com/definitelyme/flutter_paystack.git
      ref: a4a33c3dd0a12f46d655a2e63d11e9f20ba82d01

  flutter_braintree: ^2.0.0+1
  loading_overlay: ^0.3.0
  lazy_load_scrollview: ^1.3.0
  shimmer: ^2.0.0
  in_app_review: ^2.0.3
  image_cropper: ^1.5.0
  ntp: ^2.0.0
  uuid: ^3.0.4
  cron: ^0.3.2
  dotted_border: ^2.0.0+1
  translator: ^0.1.7

  firebase_core: ^1.6.0
  
  firebase_messaging: ^10.0.9
  firebase_analytics: ^8.3.4
  firebase_dynamic_links: ^3.0.1

  easy_localization_loader: ^1.0.0
  
  sentry_flutter: ^6.0.1
  twilio_phone_verify: ^2.0.0
  flutter_local_notifications: ^9.0.1
  flutter_dotenv: ^5.0.2


  flutter_localizations:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter

回答1

使用替代https://pub.dev/packages/mobile_scanner。此库在 Flutter 3.0 中不起作用。否则,如果您想使用 qr_code_scanner 库,那不是官方的创建者存储库,但您可以使用它。

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

回答2

而不是给 qr_code_scanner: ^0.5.2 尝试 qr_code_scanner: any。这只是一种解决方法。它将自动获取相关版本的 QR 扫描仪。如果它不起作用尝试 flutter clean 然后 flutter run

相似文章

最新文章