skip to Main Content
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

2

Answers


  1. Chosen as BEST ANSWER

    after a bit research and struggle i found that after passing options its working ,

     await Firebase.initializeApp(
          options: FirebaseOptions(
        apiKey: 'key',
        appId: 'id',
        messagingSenderId: 'sendid',
        projectId: 'myapp',
        storageBucket: 'myapp-b9yt18.appspot.com',
      )
        );
    

    created new app, and configured it with cli mode it will generate the options file for all platforms. Just add google-services.json won't be enough from flutte 3.19 it seems

    firebase 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

    await Firebase.initializeApp(
          options: DefaultFirebaseOptions.currentPlatform
        );
    

    consider an upvote if it helps :)


  2. I’ve also ran into this issue when using flavors in my flutter application, and ran into this when running my flavors on an android emulator.

    It’s worth ensuring that your google-services.json that you add into your project is accurate. Also – when configuring flutter fire the app/build.gradle file seems to be what flutter fire looks at. My issue was that my namespace value was not up to date with what was in Firebase and fixing that allowed me to run my android builds. Then I don’t need the options added to firebase.initializeapp

    android {
    namespace "example.example.example"
    compileSdkVersion 34

    It’s also worth checking your MainActivity.kt to ensure your package name is updated as well

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search