76

Suddenly this error appears in the debug console. I do not know what I did wrong.

Error image

4
  • 1
    are you using agora??? Commented Jul 6, 2022 at 8:32
  • No I'm not using agora Commented Jul 7, 2022 at 14:10
  • This helped me : stackoverflow.com/a/70467105/15823478 Commented Feb 27, 2023 at 16:38
  • I had the same problem and what worked for me was upgrading the firebase packages and installing the podfile again Commented Aug 29 at 22:34

17 Answers 17

105

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.

Sign up to request clarification or add additional context in comments.

11 Comments

flutter upgrade, flutter clean, flutter pub get will also do the job
Not worked. Flutter version: 3.0.5 Dart: 2.17.6
You can just upgrade the firebase_core package to the latest. That fixed the issue for me.
The upgrade command is wrong. The correct command is: flutter pub upgrade outdated_package or more specifically: flutter pub upgrade firebase_core. Can you fix this? I'm willing to bet it's causing folks some lost time.
Oh I use Android Studio and I tried restarting Android Studio and it worked, so the above instructions still work
|
14

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.

You can do this by overriding these functions as follows in AppDelegate.swift:

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {

    var flutterViewController: FlutterViewController!

    override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // Wherever your FlutterViewController is in your view hierarchy, you need to get a reference to it:
        let navController = window!.rootViewController as! UINavigationController
        self.flutterViewController = navController.children.first as! FlutterViewController

        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }

    // Add these overrides to redirect all the FlutterAppDelegate functions to your flutterViewController:

    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)
    }

}

6 Comments

This answer really needs more upvotes. The error happens exactly because of this. Sometimes the plugin registrar files are just out of date (or missing) and the commands in other answers fix them, but in some cases you might setup FlutterViewController wrong - especially in case of not having FlutterAppDelegate. So this answer gives you the correct direction. Helped me out a lot @jonathan, thanks!
Thank you for looking into the root cause. I then solve the problem by adding GeneratedPluginRegistrant.register(with: ... as the documentation said. (I was using the codes in Create a FlutterViewController with an implicit FlutterEngine section of the document so I somehow missed that PluginRegistrant thing.)
Oh and by the way, if your FlutterViewController is inside a UINavigationController, you'll also find that SystemChrome.setPreferredOrientations() won't work either. I've just posted a workaround to that problem here (posting here as I reckon people will be looking at this answer who are likely to run into this issue!)
Can u please add more detail were to add these lines which file. I am facing this issue in Android bot in iOs
sounds like I'm having the same issue but I'm not good with iOS or swift to implement this solution. Can you simplify this, a step by step guide?
|
7

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)

3 Comments

It's not firebase_core, it's path_provider for the root reason caused this issue.
Upgrading to the latest version doesn't seem to fix this issue
works for me, thx
5

Running flutter clean and flutter pub get worked for me.

Comments

4

In my case, This line was missing in MainAcitivty.java

GeneratedPluginRegistrant.registerWith(flutterEngine);

with it's import

import io.flutter.plugins.GeneratedPluginRegistrant;

enter image description here

1 Comment

This solved my problem after upgrading to android sdk 35. No package upgrades necessary.
3

As of 9th July, 2025. I updated my Dart environment.

environment:
  sdk: ^3.8.1

Then I also updated all firebase dependencies to the latest version.

  dependencies:
  firebase_analytics: ^11.5.2
  firebase_app_check: ^0.3.2+9
  firebase_auth: ^5.6.2
  firebase_core: ^3.15.1
  firebase_crashlytics: ^4.3.9
  firebase_messaging: ^15.2.9
  firebase_performance: ^0.10.1+9
  firebase_storage: ^12.4.9
  firebase_ui_firestore: ^1.7.2 
  dev dependencies:
  firebase_auth_platform_interface: ^7.7.2 
  firebase_core_platform_interface: ^6.0.0

After that, I run:
flutter clean
flutter pub get

And that resolved the issue.

1 Comment

It works for me. - Flutter 3.27.4 - xCode: 16.4
2

I was facing the same issue, After 1 day of trying, I realized that the variable I was passing to createUserWithEmailAndPassword() had no value. This function was working totally fine when I was passing hardcoded value i.e. email & password

Comments

1

Please also check the compileSdkVersion in android/app/build.gradle and update it to 33

Comments

1

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

Comments

0

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.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
0

In my case i was trying to use "google_mobile_ads" and "admob_flutter" at the same time. You must choose one only.

Comments

0

Try out different devices like Chrome or Android if you run into this error. Note that firebase does not run on all platforms flutter runs on.

In my case I was developing on Linux and got that PlatformException because I was launching the app as a Linux program - which is not supported by Firebase and thus raises the error even though everything is configured correctly.

Comments

0

for me only flutter pub cache clean helped with the issue

Comments

0

Adding GeneratedPluginRegistrant.registerWith(flutterEngine); to MainActivity.kt did work for me.

import io.flutter.plugins.GeneratedPluginRegistrant

//...

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
   super.configureFlutterEngine(flutterEngine)
   GeneratedPluginRegistrant.registerWith(flutterEngine);
   configureChannels(flutterEngine)
}

Sousce:
https://github.com/firebase/flutterfire/issues/9113#issuecomment-1188429009

Comments

-1

I was have this problem. after downgrade awesome_notifications package to 0.6.21, resolved this.

Comments

-1

I had same problem with webview_flutter package , after longtime and more search found this package has confilic with one another packages in may case it was "wear" package , after delete that its worked

Comments

-1

Posting on 19 March 2025.

first I would suggest to upgrade the flutter firebase packages (including firebase_core, firebase_auth) .

flutter pub outdated

flutter pub upgrade outdated_package

project > app > build.gradle [update compileSdk, minSdk ]

android {
    namespace = "com.example.pixelplayapp" //your app namespace
    compileSdk = 35
    ndkVersion = 30

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    // if youre using gradle 8.1.1-8.3.4
     dependencies {
        coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3' 
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.pixelplayapp"
        // You can update the following values to match your application needs.
        // For more information, see: https://flutter.dev/to/review-gradle-config.
        minSdk = 23
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

flutter clean

flutter pub get

flutter run. By doing so I have fixed my issue.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.