0

I created a simple Flutter app using the default template and made a few changes to it. It was working fine until I tried to add some plugins, then it started complaining about this. I tried various proposed fixes but then I started getting this error:

AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.myapp. Make sure to call FirebaseApp.initializeApp(Context) first.

I eventually gave up and went back to the previous working state (as far as I know) and ran flutter clean. However flutter clean does not appear to actually clean everything because I still get the error.

I have never added anything to do with Firebase! And I didn't get that error when I first created the app. What is going on?

1
  • Did you removed all unwanted libraries from your pubspec.yaml . Could you please post it? Moreover, is this project under versioning? Dec 15, 2018 at 18:03

1 Answer 1

1

The problem was that I was depending on android_alarm_manager. I thought that was fine, because I added it and did hot-reload and everything worked ok (at least the app didn't crash immediately). However you only get the Firebase error when you do a proper rebuild (flutter run).

But why does an alarm manager depend on Firebase? I don't know but.. it does. I know WTF right?

Its readme also doesn't mention anything about this, or the fact that you have to call FirebaseApp.initializeApp(Context) or whatever.

3
  • 1
    Coincidentally someone opened an issue about this this very hour: github.com/flutter/flutter/issues/25417
    – Timmmm
    Dec 15, 2018 at 18:10
  • From looking at the code, it looks like the Flutter sample for the alarm manager uses Firebase Authentication. So the dependency should just be specified for the sample app, not for the library. Reporting this on the repo is the correct approach here. Dec 15, 2018 at 18:28
  • I ran into this issue with the qr_mobile_vision package. I decided to upgrade to the latest version without reading the details there. Thanks to your post (not sure why the down vote?) and answer, I read their notes more carefully, and found this: "If you are only targeting android and don't want to switch to Firebase Mobile Vision from Google Mobile Vision, use a 0.* version of the plugin."
    – Gene Bo
    Jun 28, 2020 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.