0

未处理的异常:MissingPluginException(在通道 plugins.flutter.io/url_launcher 上找不到方法 canLaunch 的实现)

使用任何插件时出现此错误。上述错误来自使用 url_launcher。我也使用 image_picker 得到类似的错误。

这是我的 pubspec.yml 依赖列表

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.0
  flutter_facebook_login: ^3.0.0
  email_validator: ^2.0.1
  image_picker: ^0.8.4+1
  http: ^0.13.3
  get_it: ^7.2.0
  url_launcher: ^6.0.10

这是颤振医生 -v 的回复

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.1 20C69 darwin-x64, locale en-GB)
• Flutter version 2.2.3 at /Users/tarekfaysal/fvm/versions/stable
• Framework revision f4abaa0735 (3 months ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /users/tarekfaysal/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.11.0

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
   https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
   https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.60.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.26.0

[✓] Connected device (2 available)
• Mi A2 (mobile) • fff60a • android-arm64  • Android 10 (API 29)
• Chrome (web)   • chrome • web-javascript • Google Chrome 94.0.4606.61

• No issues found!

我尝试“flutter clean”并从本地设备卸载应用程序并执行“flutter run”,但此错误仍然存​​在。

请帮忙!

4

1 回答 1

0

文档所示,您需要将其添加到您的 androidManifest.xml 文件中(适用于 android):

<queries>
  <!-- If your app opens https URLs -->
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="https" />
  </intent>
  <!-- If your app makes calls -->
  <intent>
    <action android:name="android.intent.action.DIAL" />
    <data android:scheme="tel" />
  </intent>
  <!-- If your sends SMS messages -->
  <intent>
    <action android:name="android.intent.action.SENDTO" />
    <data android:scheme="smsto" />
  </intent>
  <!-- If your app sends emails -->
  <intent>
    <action android:name="android.intent.action.SEND" />
    <data android:mimeType="*/*" />
  </intent>
</queries>

对于 IOS,将其添加到您的 Info.plist 文件中:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>https</string>
  <string>http</string>
</array>

注意:您需要停止并重新启动应用程序才能看到更改(在您的模拟器中)

于 2022-02-17T22:51:25.717 回答