skip to Main Content

why doesn’t initializeApp() work? do i need another package? I get this error : The method ‘initializeApp’ isn’t defined for the type ‘FirebaseApp’

    import 'package:firebase_core/firebase_core.dart';
        
        void main(){
           Firebase.initializeApp();
           FirebaseApp.initializeApp();
        ...

3

Answers


  1. Chosen as BEST ANSWER

    FirebaseApp.initializeApp() can't be used in the main.dart, it's for MainActivity and you need these packages

    In MainActivity

    import com.google.firebase.FirebaseApp;
    import com.google.firebase.appcheck.FirebaseAppCheck;
    import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory;
    

    In pubspec.yaml

    firebase_app_check: ^0.1.1+8
    

  2. There’s nothing in the documentation that says you should call a method initializeApp on FirebaseApp. The method really doesn’t exist as the error message says.

    You just get a FirebaseApp object back from Firebase.initializeApp().

    See:

    Login or Signup to reply.
  3. I think if you are using one of the latest firebase packages you need to use the new Firebase CLI way of configuring. Check this out https://firebase.flutter.dev/docs/cli/. Overall it’s the installation process of FlutterFire across all supported platforms.
    You can also follow through this answer https://stackoverflow.com/a/73774075/10698100

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