Home:ALL Converter>Firebase initialization error on flutter MissingPluginException

Firebase initialization error on flutter MissingPluginException

Ask Time:2021-05-29T01:11:29         Author:Sanchay Kasturey

Json Formatter

I am developing an app in flutter I am using firebase in this app. And I am using following dependencies:

firebase_messaging: ^10.0.0
firebase_core: ^1.2.0
cloud_firestore: ^2.2.0
firebase_storage: ^8.1.0

I am initializing firebase like this:

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}

This whole code was working fine till today's morning but after that it is giving this error everytime:

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:53273/b_8_mVgWJY0=/ws
Syncing files to device sdk gphone x86...
I/flutter (15902): completed
E/flutter (15902): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled  Exception: MissingPluginException(No implementation found for method  Firebase#initializeCore on channel plugins.flutter.io/firebase_core)
E/flutter (15902): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7)
E/flutter (15902): <asynchronous suspension>
E/flutter (15902): #1      MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:344:35)
E/flutter (15902): <asynchronous suspension>
E/flutter (15902): #2      MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:30:23)
E/flutter (15902): <asynchronous suspension>
E/flutter (15902): #3      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:77:7)
E/flutter (15902): <asynchronous suspension>
E/flutter (15902): #4      Firebase.initializeApp (package:firebase_core/src/firebase.dart:41:31)
E/flutter (15902): <asynchronous suspension>
E/flutter (15902): 

Is there anything wrong with android studio or flutter SDK itself? I have also noticed that there is one file generated that was not there earlier when the app was working fully functional the file is named "generated_plugin_registrant.dart".

Update: I removed flutter from my windows and again installed it but it didn't work as well. Now I think I should uninstall android studio completely and again install it because I don't find any error or wrong implementation in my code till now, Please tell me if there is any.

Please help me.

Thanks for your replies.

Author:Sanchay Kasturey,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/67743041/firebase-initialization-error-on-flutter-missingpluginexception
Sanchay Kasturey :

I searched a lot on the internet but the solution was very simple. It was happening because the following code was missing in my MainActivity.kt.\nCode:\noverride fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {\nGeneratedPluginRegistrant.registerWith(flutterEngine); }\nIt was not registering the flutter plugins that's why it was giving an error it took me 2 and a half days I hope if someone else is facing this issue they can solve it earlier than me.\nAnd thanks for all your replies.",
2021-05-30T05:57:47
Shameem Reza :

I had the same problem. I also tried many solution like you, but could not able to resolve it issues.\nLatter, I ended up creating a new project carefully copying firebase and multiple other packages from the original project. After that I copied every single file in lib/android along with their respective configurations in build.gradle and manifests. For iOS I just copied the entire project and that worked immediately.\nYou also can try like my. Create a new project and copy everything from your old project to new one, one by one to see this issue resolved or not.",
2021-05-29T05:00:27
Padi :

Try running\nflutter clean\nflutter pub get\n\nin the terminal and see if that helps",
2021-05-28T17:30:10
yy