E/flutter ( 6571): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(java.lang.Exception: Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly., Exception, Cause: null, Stacktrace: java.lang.Exception: Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly.
E/flutter ( 6571): at io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin.lambda$optionsFromResource$4$io-flutter-plugins-firebase-core-FlutterFirebaseCorePlugin(FlutterFirebaseCorePlugin.java:207) E/flutter ( 6571): at io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin$$ExternalSyntheticLambda2.run(Unknown Source:4) E/flutter ( 6571): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) E/flutter ( 6571): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) E/flutter ( 6571): at java.lang.Thread.run(Thread.java:1012) E/flutter ( 6571): , null) E/flutter ( 6571): #0 FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:242:7) E/flutter ( 6571): E/flutter ( 6571): #1 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25) E/flutter ( 6571): E/flutter ( 6571): #2 Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:31)
error throws right after calling await Firebase.initializeApp();
its happening after removing imperative apply of Flutter's Gradle plugins which is deprecated.
ie. after migrate to the new, declarative apply issue started.
checked by creating new project also facing same issue
settings.gradle file snap
*app building for ios and android not web
env:
firebase_core: ^2.27.1
flutter doctor result
any help to fix this issue would be appreciated. thankz
after a bit research and struggle i found that after passing
optionsits working ,created new app, and configured it with cli mode it will generate the options file for all platforms. Just add
google-services.jsonwon't be enough from flutte 3.19 it seemsfirebase cli config
Good luck.
once the files are generated your firebaseinit code should look like this options are applied through CLI geneteated options file according to platform
consider an upvote if it helps :)