简体   繁体   中英

ERROR:flutter/runtime/dart_vm_initializer.cc(41) on url_launcher

I use HTTP launcher and found this error on my console log after I run debug on my android studio emulator:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher_android)

This is the code where it throw error:

Future<void> _launchMap() async {
    final url = widget.website;
    var uri = Uri.parse(url);
    if (!await launchUrl(uri)) {
      throw 'Could not launch';
    }
  }

this is my android manifest:

       <queries>
            <!-- If your app checks for call support -->
            <intent>
                <action android:name="android.intent.action.VIEW" />
                <data android:scheme="tel" />
            </intent>
            <intent>
                <action android:name="android.intent.action.VIEW" />
                <data android:scheme="https" />
            </intent>
        </queries>

I use the newest flutter version and I already follow the guide from https://pub.dev/packages/url_launcher , but it still can't direct the link that I want from my API

If you are using hot restart or hot reload, it won't do the trick. Since Flutter has to inject plugin dependencies into the platform-specific parts of your app, hot restart/hot reload is not enough to trigger the injection. Check this issue for more.

Close the app and execute flutter run command.

Try the following code:

Future<void> _launchMap() async {
       final url = widget.website;
       var uri = Uri.parse(url);
    if (await canLaunchUrl(url)) {
       await launchUrl(url);
   } else {
       throw 'Could not launch $url';
}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM