簡體   English   中英

未處理的異常:MissingPluginException(在通道插件上找不到方法 X 的實現。flutter.io/Y)

[英]Unhandled Exception: MissingPluginException(No implementation found for method X on channel plugins.flutter.io/Y)

我已按照此處的步驟將我的 flutter 項目遷移到 null 安全。

從那時起,我時不時地在以下多個軟件包中遇到此錯誤。

Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

以上是shared_preferences ,但path_providerfirebase_analytics會拋出類似的錯誤。

這是我的pubspec.yaml

name: news_app
description: A news app

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.10+22

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  curved_navigation_bar: ^1.0.1
  http: ^0.13.4
  webview_flutter: ^2.8.0
  firebase_core: ^1.10.6
  firebase_auth: ^3.3.4
  flutter_cache_manager: ^3.3.0
  flutter_widget_from_html_core: ^0.8.4
  flutter_widget_from_html: ^0.8.0
  flutter_html: ^2.1.5
  page_view_indicators: ^2.0.0
  splashscreen: ^1.3.5
  intl: ^0.17.0
  jiffy: ^5.0.0
  dio: ^4.0.4
  dio_http_cache: ^0.3.0
  shared_preferences: ^2.0.6
  connectivity: ^3.0.6
  share: ^2.0.4
  sqflite: ^2.0.1
  path_provider: ^2.0.2
  timeago: ^3.1.0
  auto_size_text: ^3.0.0
  flutter_tts: ^3.3.2
  firebase_messaging: ^11.2.4
  firebase_analytics: ^9.0.4
  flutter_local_notifications: ^9.1.5
  chewie: ^1.2.2
  flutter_svg: ^0.22.0
  provider: ^5.0.0
  webview_flutter_plus: ^0.2.3+1
  firebase_admob: ^0.11.2
  scroll_app_bar: ^2.0.0
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.4

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: ^0.9.2

flutter_icons:
  image_path: "assets/logo.jpg"
  android: true
  ios: true

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  fonts:
    - family: sourcePro
      fonts:
        - asset: assets/SourceSansPro-Light.ttf
    - family: serifPro
      fonts:
        - asset: assets/SourceSerifPro-Light.otf
    - family: metaSerifPro
      fonts:
        - asset: assets/FFMetaSerifPro-Light.ttf
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  assets:
    - assets/logo.jpeg
    - assets/tbs_logo_transparent.png
    - assets/logo.png
    - assets/logo.jpg
  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

這是flutter doctor的結果

[✓] Flutter (Channel stable, 2.5.3, on Ubuntu 16.04.7 LTS 4.15.0-142-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.63.2)
[✓] Connected device (3 available)

我嘗試了從其他帖子中發現的以下措施,以及 github 問題。

  1. 我嘗試切換到不同flutter頻道。
  2. 還嘗試更改上述軟件包的版本。
  3. 嘗試使用flutter clean刪除緩存。
  4. 我卸載了應用程序並重新安裝了它,仍然一樣。
  5. 重新安裝了所有軟件包。
  6. 使緩存無效后重新啟動 Android Studio。

它沒有任何工作。 在遷移到 null 之前,安全工作正常。

我可以建議你換一種方式。 不要將現有項目遷移到 null 安全性,而是創建新項目(具有 null 安全性)並從舊項目復制lib文件夾。 然后將您從舊的pubspec.yaml文件安裝到新的pubspec.yaml文件中添加軟件包(確保您擁有最新版本。)。 (以及資產和 fonts,如果有)。 如果您添加的軟件包需要針對 iOS 和 Android 平台進行額外集成,請執行此操作。 我以這種方式更新舊版本的 lutter(即非空安全)項目。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 FLUTTER 未處理的異常:MissingPluginException(在通道插件上找不到方法 map#waitForMap 的實現。flutter.io/google_maps_0) Flutter Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker) 錯誤 未處理的異常 MissingPluginException:在通道 plugins.flutter.io/firebase_core 上找不到方法 Firebase#initializeCore 的實現 未處理的異常:MissingPluginException(在頻道 plugins.flutter.io/google_mobile_ads 上找不到方法 _init 的實現)in_app_purchase MissingPluginException(MissingPluginException(在通道 plugins.flutter.io/firebase_core 上找不到方法 Firebase#initializeCore 的實現) MissingPluginException(未在通道插件上找到方法 init 的實現。flutter.io/google_sign_in) MissingPluginException(在 Android 上找不到方法 Firebase#initializeCore 在通道插件上的實現。flutter.io/firebase_core) MissingPluginException(在通道 plugins.flutter.io/path_provider 上找不到方法 getApplicationDocumentsDirectory 的實現) 缺少插件異常(在通道插件上找不到方法 firebase#initializecore 的實現。flutter.io/firebase_core) MissingPluginException(MissingPluginException(未找到方法 camera#animate on channel plugins.flutter.io/google_maps_53)的實現)
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM