I'm trying to open a URL but I get this Error, when I run an android app on the emulator or in a device the result on the screen is that nothing happens but I get "Unhandled Exception: MissingPluginException", but when I use windows app works fine.
launchUrl support: android, windows, ios
E/flutter ( 6260): [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) E/flutter ( 6260): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:294:7) E/flutter ( 6260): E/flutter ( 6260): #1 _launchURL (package:peliculas/screens/details_cast.dart:371:8) E/flutter ( 6260):
My code:
Future<void> _launchURL(String url) async {
final Uri uri = Uri(scheme: "https", host: url);
if (!await launchUrl(uri)) {
throw 'Could not launch $url';
}
-I'm using url ="www.google.com" -emulator api 30
What I tried before:
- flutter clean
- flutter pug get
- flutter run
- uninstall app
- flutter doctor -v is OK
- I'm not using hot restart or hot reload
UPDATE: It happen in other projects but now is just in this one, I have another project where I use only this method and after updating closing and opening again starts to work but the main project didn't work. I move the project to another place and open but I get the same.
SOLUTION: To solve this problem, in my case that url_launcher didn't work in my project but when I create a new one it works fine, just follow what "FirstComment" says, create a new project copy the lib folder to the new one, and set Manifest and pubspec configuration like the old project, also move other files like asset.
run these commands in terminal
1 :
flutter clean2 :
flutter pub getand Restart your app