Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase configuration #174

Open
jempis opened this issue May 17, 2023 · 7 comments
Open

Firebase configuration #174

jempis opened this issue May 17, 2023 · 7 comments

Comments

@jempis
Copy link

jempis commented May 17, 2023

Hi all,
i have try to implement the flutter_flavorizr with 2 flavors e two relative firebase projects.
This is the configuration in pubspec.yaml

flavorizr:
  app:
    android:
      flavorDimensions: "flavor-type"
    ios:
  flavors:
    development:
      app:
        name: "Toov Dev"

      android:
        applicationId: "com.example.toov.app.dev"
        firebase:
          config: "config/development/google-services.json"

      ios:
        bundleId: "com.example.toov.app.dev"
        firebase:
          config: "config/development/GoogleService-Info.plist"

    production:
      app:
        name: "Toov"

      android:
        applicationId: "com.example.toov.app.app"
        firebase:
          config: "config/production/google-services.json"
      ios:
        bundleId: "com.example.toov.app"
        firebase:
          config: "config/production/GoogleService-Info.plist"
  ide: "idea"

After launch
flutter pub run flutter_flavorizr i run app (with launch view) without a problem.
But, after i add in app the firebase authentication, on run app return this error

  E/flutter (26119): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
E/flutter (26119): #0      MethodChannelFirebase.app (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:193:5)
E/flutter (26119): #1      Firebase.app (package:firebase_core/src/firebase.dart:56:41)
E/flutter (26119): #2      FirebaseAuth.instance (package:firebase_auth/src/firebase_auth.dart:44:47)
E/flutter (26119): #3      new AuthenticationRepository (package:toover/data/repositories/AuthenticationRepository.dart:20:68)
E/flutter (26119): #4      main (package:toover/main_development.dart:14:36)
E/flutter (26119): #5      _runMain.<anonymous closure> (dart:ui/hooks.dart:131:23)
E/flutter (26119): #6      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:296:19)
E/flutter (26119): #7      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
E/flutter (26119): 

Then i try to add this

await Firebase.initializeApp(name: "App Dev");

but return this:

E/flutter ( 8394): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)
E/flutter ( 8394): #0      FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:248:7)
E/flutter ( 8394): <asynchronous suspension>
E/flutter ( 8394): #1      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25)
E/flutter ( 8394): <asynchronous suspension>
E/flutter ( 8394): #2      Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:31)
E/flutter ( 8394): <asynchronous suspension>
E/flutter ( 8394): #3      main (package:toover/main_development.dart:14:3)
E/flutter ( 8394): <asynchronous suspension>
E/flutter ( 8394): 

i call the instance of FirebaseAuthentication with
firebase_auth.FirebaseAuth.instance;

i forgot to configure something?

Thanks

@AngeloAvv
Copy link
Owner

Hello @jempis, simply instantiate Firebase without passing any params:

await Firebase.initializeApp();

@jempis
Copy link
Author

jempis commented Jun 7, 2023

Hi @AngeloAvv ,
thank for response but with passing or not any params when call Firebase.initializeApp(), the error is the same

E/flutter ( 8504): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)
E/flutter ( 8504): #0      FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:248:7)
E/flutter ( 8504): <asynchronous suspension>
E/flutter ( 8504): #1      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25)
E/flutter ( 8504): <asynchronous suspension>
E/flutter ( 8504): #2      Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:31)
E/flutter ( 8504): <asynchronous suspension>
E/flutter ( 8504): #3      main (package:toover/main_development.dart:15:3)
E/flutter ( 8504): <asynchronous suspension>
E/flutter ( 8504): 

@mafreud
Copy link

mafreud commented Jul 3, 2023

@AngeloAvv
This worked for me. Thank you.

Hello @jempis, simply instantiate Firebase without passing any params:

await Firebase.initializeApp();

@AngeloAvv
Copy link
Owner

@jempis sounds like you forgot to add dependencies in the build.gradle files.

@jempis
Copy link
Author

jempis commented Jul 25, 2023

Sorry @AngeloAvv , but what are this dependencies?
there aren't this dependencies in the tutorial..

@AngeloAvv
Copy link
Owner

@jempis you have to follow the one without flutterfire CLI: https://firebase.flutter.dev/docs/manual-installation

@yacine-h-brahim
Copy link

yacine-h-brahim commented Feb 16, 2024

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Platform.isAndroid
      ? await Firebase.initializeApp(
          options: FirebaseOptions(
            apiKey: "ApiKey",
            appId: "AppId",
            messagingSenderId: "MessagingSenderId",
            projectId: "ProjectId",
          ),
        )
      : await Firebase.initializeApp();

  runApp(const MainApp());
}

-follow this youtube video for more: https://www.youtube.com/watch?v=Qn2ysnVMvEE
-happy coding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants