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_core] use with Firebase Emulator demo project. #9507

Open
bsr203 opened this issue Sep 9, 2022 · 4 comments · May be fixed by #11973
Open

[firebase_core] use with Firebase Emulator demo project. #9507

bsr203 opened this issue Sep 9, 2022 · 4 comments · May be fixed by #11973
Labels
platform: all Issues / PRs which are for all platforms. plugin: core type: bug Something isn't working type: documentation Improvements or additions to documentation

Comments

@bsr203
Copy link

bsr203 commented Sep 9, 2022

This is reported previously. Please refer to #8898

What works:

  • run flutterfire configure and create the option file.
  • load it through
  await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
)
..

// set the emulators
FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080);
await FirebaseAuth.instance.useAuthEmulator('localHost', 9099);

now you can connect to the emulator running with the actual project id (same used to configure through flutterfire configure)

What doesn't work:

We recommend you use demo projects wherever possible. Benefits include:

Easier setup, since you can run the emulators without ever creating a Firebase project
Stronger safety, since if your code accidentally invokes non-emulated (production) resources, there is no chance of data change, usage and billing
Better offline support, since there is no need to access the internet to download your SDK configuration.

  • if you use the flutter fire configuration like
  await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
)

it starts up the app, but connect with real project not the emulator.
That is if you seed the demo-test project (firestore, auth,..) you won't see it in the app.

I tried with changing the projectId alone in the FirebaseOptions. Which causes a crash

Connecting to VM Service at ws://127.0.0.1:51172/ATxL0xfCjfA=/ws
2022-09-09 16:37:17.438 myapp[14449:1525198] *** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007ff8191597c3 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff818eb9bc3 objc_exception_throw + 48
	2   CoreFoundation                      0x00007ff81915962a +[NSException exceptionWithName:reason:userInfo:] + 0
	3   FirebaseCore                        0x000000010f0d7f9e +[FIRApp addAppToAppDictionary:] + 254
	4   FirebaseCore                        0x000000010f0d7203 +[FIRApp configureWithName:options:] + 1347
	5   myapp                                0x000000010ef0bfd4 -[FLTFirebaseCorePlugin initializeAppAppName:initializeAppRequest:completion:] + 2308

if I remove all config, like

await Firebase.initializeApp();
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized.
Usually this means you've attempted to use a Firebase service before calling `Firebase.initializeApp`.
View the documentation for more information: https://firebase.flutter.dev/docs/overview#initialization

so how would you connect to the emulator which is running a demo project .

cc @russellwheatley

@bsr203 bsr203 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Sep 9, 2022
@darshankawar darshankawar added the triage Issue is currently being triaged. label Sep 12, 2022
@darshankawar
Copy link

Thanks for the report @bsr203
I tried the scenario you mentioned, but didn't get the error you reported.

  1. I have the demo project configured and running:

Screenshot 2022-09-12 at 4 45 40 PM

  1. Used firebase_auth_example plugin that has FirebaseAuth emulator setup and configured:

Screenshot 2022-09-12 at 4 34 27 PM

This error Terminating app due to uncaught exception 'com.firebase.core', reason: 'Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options.' *** First throw call stack: probably indicates GoogleService-Info.plist is not in sync or configured per the platform.

how would you connect to the emulator which is running a demo project .

Please check this and see if it helps.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Sep 12, 2022
@bsr203
Copy link
Author

bsr203 commented Sep 12, 2022

@darshankawar I have seen that SO link, and similar.

You are getting GoogleService-Info.plist error because, you haven't run flutterfire configure which downloads the firebase configuration files.

Once you configure, you have a catch22 situation where you have to initialize it with the real configuration, which then would not connect to the demo project.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Sep 12, 2022
@darshankawar
Copy link

Thanks for the feedback.
Keeping this issue open and labeling for further insights from the team on expected behavior when connect to the emulator which is running a demo project.

/cc @russellwheatley

@darshankawar darshankawar added plugin: core type: documentation Improvements or additions to documentation and removed triage Issue is currently being triaged. Needs Attention This issue needs maintainer attention. labels Sep 13, 2022
@Turburlar
Copy link

This is an issue I am facing as well. @darshankawar I think the desired solution, is that when running flutterfire configure, you are given the option to select 'use demo project' or something similar.

Related note. The firebase docs recommend using demo projects with the emulator when possible, but then go into absolutely ZERO detail about how it should be done. This fact, in addition to the fact that it is clear the FlutterFire team has given very little thought into how to run a demo project, all comes of as Firebase is not even a production ready service. I hope one day Firebase will get their act together and present itself as a tool for serious application development.

@Lyokone Lyokone linked a pull request Jan 5, 2024 that will close this issue
10 tasks
@Lyokone Lyokone added the platform: all Issues / PRs which are for all platforms. label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: all Issues / PRs which are for all platforms. plugin: core type: bug Something isn't working type: documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants