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

fix: 'Flutter.initializeApp' error on Android #8535

Closed
wants to merge 6 commits into from

Conversation

ihorvitruk
Copy link

@ihorvitruk ihorvitruk commented Apr 28, 2022

Description

Error:

E/flutter ( 6109): [ERROR:flutter/runtime/dart_vm_initializer.cc(39)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized.
E/flutter ( 6109): 
E/flutter ( 6109): Usually this means you've attempted to use a Firebase service before calling `Firebase.initializeApp`.
E/flutter ( 6109): 
E/flutter ( 6109): View the documentation for more information: https://firebase.flutter.dev/docs/overview#initialization
E/flutter ( 6109):     
E/flutter ( 6109): #0      MethodChannelFirebase.initializeApp (package:*******.flutter_plugins.firebase_core.interface/src/method_channel/method_channel_firebase.dart:99:9)
E/flutter ( 6109): <asynchronous suspension>
E/flutter ( 6109): #1      Firebase.initializeApp (package:firebase_core/src/firebase.dart:40:31)
E/flutter ( 6109): <asynchronous suspension>

Bug explanation:
Default FirebaseApp is not created, if FirebaseOptions instanceis not passed directly toFirebase.initializeApp` function.

Fix explanation:

  • modify MethodChannelFirebase to create default app also if options are null
  • modify [FlutterFirebaseCorePlugin.java to check whether options are null. If yes - retrieve firebase options from resource:
options = FirebaseOptions.fromResource(applicationContext);

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See [Contributor Guide]).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the [Flutter Style Guide].
  • I signed the [CLA].
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@google-cla
Copy link

google-cla bot commented Apr 28, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

For more information, open the CLA check for this pull request.

@ihorvitruk ihorvitruk changed the title Fix Flutter.initializeApp' error on Android Fix 'Flutter.initializeApp' error on Android Apr 28, 2022
@ihorvitruk ihorvitruk changed the title Fix 'Flutter.initializeApp' error on Android Fix: 'Flutter.initializeApp' error on Android Apr 28, 2022
@ihorvitruk ihorvitruk changed the title Fix: 'Flutter.initializeApp' error on Android fix: 'Flutter.initializeApp' error on Android Apr 28, 2022
@Salakar
Copy link
Member

Salakar commented May 3, 2022

I couldn't push changes to this PR so I've pushed to a new branch and made a replacement PR: #8566

@Salakar Salakar closed this May 3, 2022
@firebase firebase locked and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage Issue is currently being triaged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants