Skip to content

[firebase_messaging] Android v2 embedding crashes #1754

@cranst0n

Description

@cranst0n

Describe the bug
Since updating my app to the Android v2 embedding I've been getting reports in Crashlytics concerning ensureInitializationComplete must be called after startInitialization io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete.

The Flutter 1.12 upgrade guide says to remove all references to the startInitialization or ensureInitializationComplete methods but I see 2 references to these methods: here and here.

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade app to v2 embedding.
  2. Start app and then close it.
  3. Send notification from the Firebase Notification Composer.
  4. Notice app crash notification on device.
  5. See error or incorrect behavior

I have not seen the issue when I leave the app open and send the notification.

Expected behavior
Notification displayed normally while app is closed.

Additional context
Here is what the Crashlytics report looks like:

Fatal Exception: java.lang.RuntimeException
Unable to create service io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: java.lang.IllegalStateException: ensureInitializationComplete must be called after startInitialization
android.app.ActivityThread.handleCreateService (ActivityThread.java:3746)
android.app.ActivityThread.access$1400 (ActivityThread.java:235)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1784)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:214)
android.app.ActivityThread.main (ActivityThread.java:6986)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)

Caused by java.lang.IllegalStateException
ensureInitializationComplete must be called after startInitialization
io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete (FlutterLoader.java:153)
io.flutter.view.FlutterMain.ensureInitializationComplete (FlutterMain.java:80)
io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.onCreate (FlutterFirebaseMessagingService.java:71)
android.app.ActivityThread.handleCreateService (ActivityThread.java:3734)
android.app.ActivityThread.access$1400 (ActivityThread.java:235)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1784)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:214)
android.app.ActivityThread.main (ActivityThread.java:6986)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact: crowdAffects many people, though not necessarily a specific customer with an assigned label. (P2)plugin: messagingtype: bugSomething isn't workingtype: documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions