Suddenly this error appears in the debug console. I do not know what I did wrong.
You've upgraded Flutter but not the packages. In the terminal enter
flutter pub outdated
Then upgrade the outdated packages one by one like this:
flutter pub upgrade outdated_package
After you're finished:
flutter clean
and
flutter pub get
Your problem should now be solved.
I had the same issue and stumped on this post.
In my case I was able to detect which plugin was in fact giving the error and it turned out to be firebase_core. So, I decided to upgrade the package to the latest version which happened to be 1.21.1 in my case.
So, to solve the issue I will suggest you try changing the version of the firebase_core package you're using to the latest in the pubspec.yaml file of your project like so:
firebase_core: ^1.21.1 (replace with latest verison)
Or you can just run:
flutter pub upgrade firebase_core
This will upgrade firebase_core to the latest version.
Or you can as well put any as the version code in the pubspec.yaml file of your project like so:
firebase_core: any (upgrades firebase_core to the latest verison)
Please also check the compileSdkVersion in android/app/build.gradle and update it to 33
You are good to go with these three steps,
Flutter clean
Flutter pub get
Flutter run
If you are using these dependecies then replace it with a latest version:
firebase_messaging
firebase_core
flutter_local_notifications
Then in android/app/build.gradle update compileSdkVersion flutter.compileSdkVersion to 33
I spent a long time looking into this and eventually traced it to the plugin registrar being nil when setting up the plugin.
This was caused by setting my iOS app root view controller to anything other than FlutterViewController (i.e. in my case, I had a UINavigationController as the root). This will result in a failure to register all your plugins.
The app delegate assumes that the root view controller is a FlutterViewController, so if it isn't then you will need to re-direct all plugin-related function calls to your FlutterViewController from your app delegate by overriding these functions as follows:
override func registrar(forPlugin pluginKey: String) -> FlutterPluginRegistrar? {
flutterViewController.registrar(forPlugin: pluginKey)
}
override func hasPlugin(_ pluginKey: String) -> Bool {
flutterViewController.hasPlugin(pluginKey)
}
override func valuePublished(byPlugin pluginKey: String) -> NSObject? {
flutterViewController.valuePublished(byPlugin: pluginKey)
}
I was have this problem.
after downgrade awesome_notifications package to 0.6.21, resolved this.
I also effected from that issue for few hours, finally I found issue that was I ran my emulator as windows (:, yeah please run with Android emulator you selected vm.
for me my dependencies were up to date but I was using windows as an emulator so I switched to android emulator issue was resolved.
I'm working with Firebase in flutter (latest versions as of 1st July 2022), and when I try to call Firebase.initializeApp() in my Main function, it returns an error of:
'[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)'
Here is my code:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
Firebase.initializeApp();
runApp(const MyApp());
}
Any help would be greatly appreciated
I was able to solve the problem by upgrading all my firebase dependencies to the latest version using flutter pub outdated and flutter pub upgrade firebase_....
I encountered this issue after adding the firebase_messaging plugin v11.4.4. Might be related to the change in firebase_core_platform_interface.
Also got it after a pub update. Fixed it by doing:
flutter clean
and removing the pubspec.lock
Do a flutter clean and upgrade firebase core with
flutter pub upgrade firebase_core
The run
dart pub global activate flutterfire_cli
flutterfire configure
to reinitialize firebase. I experienced this after adding app_check support
I have updated the below dependency:
dependency_overrides:
firebase_core_platform_interface: 4.4.1
Executed this command and updated firebase dependencies
flutter pub upgrade firebase_core
flutter pub upgrade firebase_messaging
it is working properly now.
Problem seems to be with the core platform interface.
Add firebase_core_platform_interface: 4.4.0 and adjust all other firebase deps to make them compatible with this library. I downgraded all versions to 36 day old release and it finally works.
I just built a new flutter app and I got this error when initializing Firebase App and running it in the browser and not the android emulator. I am using VS Code and you can change the target device in the bottom task bar on the right side.
Solution is to run it in the android emulator. I don't know if there are permissions to be set for web view but I do not plan on deploying to web.
Had the same problem and scaled back (thank you git) - getting flutter dependencies right - as in it compiles and work as advertised is no mean feat. Welcome :)
I have this error with my Flutter app that caused by Dart SDK
I use Flutter 1.22.6 with Dart SDK 2.10.5 (stable) & intellij 2020.3 ...
when click on fix only remove shows, after remove the error goes, but then the error starts popup ...as I'm doing Android app so it's not affecting , but later for the iOS version I guess it will affect .
any idea how to solve ?
It looks like a cache problem.
Try to run the following commands:
flutter pub cache repair
flutter packages get
i just setup my android studio and vs code and flutter SDK installed but any time i try running the project i get this Gradle error, i cant figure out what the problem is please help me out.
After running the flutter doctor everything seems to be okay.
the problem might be caused by many factors so lets try some solutions
after each one rebuild your app if the error message changed or the problem solved please keep us informed
run these commands one by one
flutter channel stable
flutter upgrade --force
flutter pub cache repair
cd your app folder
flutter clean
edit app/build.gradle in your host app such as it includes the local repo
like in here
repositories {
maven {
url 'https://storage.googleapis.com/download.flutter.io'
}
}
use VPN and rebuild your app
I am implementing image_picker in my app. That is not showing any warning or message but when I run it in Android simulator it shows me an error in console:
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)
E/flutter ( 5074): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
E/flutter ( 5074): <asynchronous suspension>
E/flutter ( 5074): #1 ImagePicker.pickImage (package:image_picker/image_picker.dart:53:40)
E/flutter ( 5074): <asynchronous suspension>
I solved my problem by simply run following command:
flutter clean
After this my Android simulator start working correctly.
When you add a new dependency and you get this error, you should stop the app and run it again from cold. Hot restart will not work.
First, make sure you clean your flutter project
flutter clean
then in Android studio,
File > Invalidate and caches restart
flutter run
Just uninstall app from your simulator and clean project by flutter clean and then flutter run
I had the same issue
For anyone who happens to stumble accros this... Just Stop the app, and run it again
just a simple "turn it off and on again!"
I am facing the same issue but none of the answers mentioned above help with this problem after digging in, I find out that the minSdkVersion required for the library for android is above 19 so GO to
android-> app-> build.gradle change the minSdkVersion to 19 and run app from cold start.
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "you package name"
minSdkVersion 19 // <--here is the changes
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
For those who still having problems on Android,
this one solved mine..
For some reason image_picker plugin haven't been registered automacally
Go to Android > app > main > java> io> flutter > plugins and edit GeneratedPluginRegistrant.java
import io.flutter.plugins.imagepicker.ImagePickerPlugin;
paste this line inside method registerWith ImagePickerPlugin.registerWith(registry.registrarFor("io.flutter.plugins.imagepicker.ImagePickerPlugin"));
This happens when you add a dependency to pubsec yaml file and hot-refresh the app. You should re-build / re-run the app then it works fine.
After removing the flutter_facebook_auth package, running flutter clean, flutter pub get and running the application, it will work properly
Since the latest update the static method pickImage is not available for some reasons.
You will have to call methd getImage(source: ImageSource) for that purpose
ImagePicker imagePicker = ImagePicker();
final imageFile = await imagePicker.getImage(source: ImageSource.camera);
Android #
API < 29
No configuration required - the plugin should work out of the box.
API 29+
Add android:requestLegacyExternalStorage="true" as an attribute to the tag in AndroidManifest.xml. The attribute is false by default on apps targeting Android Q.
After that :
flutter clean
flutter pub get
flutter run
And here you go coding again...
If you are using flutter_facebook_auth you must configure it as shown in the documentation (https://facebook.meedu.app/#/android), otherwise, image_picker will not work correctly
Taken from the flutter_facebook_auth documentation
It is not a problem just When you add a new dependency and you get this error, you should stop the app and run it again.Hot restart will not work.
make sure that you give uses-permission in your AndroidManifest.xml
android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
and after that run
flutter clean
flutter pub get
flutter run
Are you picking an image from camera or gallery? if you want to pick an image from the camera you need to use a real device, simulation gives error sometimes, make sure you are giving the source:
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
Try to add :
import 'dart:async';
flutter clean
Try by changing the image_picker version: image_picker: ^0.6.0+9
Already follow all the responses but still not solve in my case. Still throwing "No implementation found for method pickImage on channel plugins.flutter.io/image_picker"
I had the same issue.
My solution was to remove another plugin: flutter-facebook-auth.
also, I found it here: github.com/flutter/flutter/issues/72898
Really informative comment:
Anyway, that's really bad situation when some plugin that is not used in the part of code crashes the app, and debug tells you that issues is with another one plugin.
Simply stop your project and Run. It will work
it is simple to fix. terminate the process and then restart. to terminate on vscode : open terminal on vscode and press " ctr + c" then press "y" and press "enter" .now restart your project .hope it will work. check it and comment me if it does not work.
Updating the dependency solve my error.