Skip to content

🐛 [Firebase Messaging] enabling backgroundMessages causes hot reload/restart to break #4316

@Chris1234567899

Description

@Chris1234567899

Bug report

In order to enable background messaging, I created a file Application.kt and referenced it. Since the docs are outdated and not in Kotlin, I went with this, as suggested in stackoverflow :

class Application : FlutterApplication(), PluginRegistrantCallback {

    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    override fun registerWith(registry: PluginRegistry?) {
       
       //GeneratedPluginRegistrant.registerWith(registry); // according to the docs, but this causes an error
       
    io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));


    }
}

This works well for receiving background messages.

I also can start the app, however after 2-3 hot reloads all further hot reloads or restarts get stuck. I don't receive any error messages, just the hot reload process never finishes. I have to completely stop the run process and start it again with F5 (using VS Code).

If I comment out the registration of the Plugin in the Application.kt, hot reload works normally so it is definately due to firebase_messaging.

Either the docs are wrong (they need an update either way) or this seems to be a bug.

Expected behavior

Having background messages and making use of the flutter hot reload functionality normally ;-)


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
flutter doctor -v
[√] Flutter (Channel master, 1.25.0-5.0.pre.53, on Microsoft Windows [Version 10.0.18363.1198], locale de-DE)
    • Flutter version 1.25.0-5.0.pre.53 at C:\flutter
    • Framework revision 20ca6997b8 (4 hours ago), 2020-12-04 01:23:04 +0800
    • Engine revision 20caf54969
    • Dart version 2.12.0 (build 2.12.0-76.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\Cri\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 45.0.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code (version 1.51.1)
    • VS Code at C:\Users\Cri\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.16.0

[√] Connected device (3 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 87.0.4280.88
    • Edge (web)                         • edge          • web-javascript • Microsoft Edge 86.0.622.56

• No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
flutter pub deps -- --style=compact
Dart SDK 2.12.0-76.0.dev
Flutter SDK 1.25.0-5.0.pre.53
micomida 1.0.0+1

dependencies:
- cupertino_icons 1.0.0
- device_info 0.4.2+9 [flutter device_info_platform_interface]
- dio 3.0.10 [http_parser path]
- dio_http_cache 0.2.11 [flutter quiver json_serializable json_annotation dio sqflite path crypto]
- easy_debounce 1.0.2 [flutter]
- email_validator 1.0.6
- enum_to_string 1.0.13
- firebase_messaging 7.0.3 [meta flutter firebase_core]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_cupertino_localizations 1.0.1 [flutter flutter_localizations]
- flutter_dotenv 2.1.0 [flutter meta]
- flutter_linkify 4.0.2 [flutter linkify]
- flutter_local_notifications 3.0.1+6 [flutter platform flutter_local_notifications_platform_interface timezone]
- flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math]
- flutter_map 0.10.1+1 [flutter tuple latlong positioned_tap_detector transparent_image async flutter_image cached_network_image sqflite path_provider vector_math proj4dart meta]
- get_it 5.0.1 [async meta]
- image_picker 0.6.7+12 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- infinite_scroll_pagination 2.2.2 [flutter sliver_tools]
- intl_phone_number_input 0.5.2+2 [flutter meta libphonenumber equatable]
- location 3.1.0 [flutter meta location_platform_interface location_web]
- multi_image_picker 4.7.14 [flutter meta]
- permission_handler 5.0.1+1 [flutter meta permission_handler_platform_interface]
- progress_dialog 1.2.4 [flutter]
- shared_preferences 0.5.12+2 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- sms_autofill 1.2.6 [pin_input_text_field flutter]
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- uuid 2.2.2 [crypto convert]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- _fe_analyzer_shared 11.0.0 [meta]
- analyzer 0.40.4 [_fe_analyzer_shared args charcode cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- ansicolor 1.0.5
- args 1.6.0
- async 2.5.0-nullsafety.3 [collection]
- boolean_selector 2.1.0-nullsafety.3 [source_span string_scanner]
- build 1.5.0 [analyzer async convert crypto logging meta path glob]
- build_config 0.4.2 [checked_yaml json_annotation meta path pubspec_parse yaml]
- cached_network_image 2.3.3 [flutter flutter_cache_manager octo_image]
- characters 1.1.0-nullsafety.5
- charcode 1.2.0-nullsafety.3
- checked_yaml 1.0.2 [json_annotation source_span yaml]
- cli_util 0.2.0 [path]
- clock 1.1.0-nullsafety.3
- collection 1.15.0-nullsafety.5
- console_log_handler 1.1.6 [logging intl ansicolor]
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- dart_style 1.3.8 [analyzer args path source_span]
- device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface]
- equatable 1.2.5 [collection meta]
- fake_async 1.2.0-nullsafety.3 [clock collection]
- ffi 0.1.3
- file 6.0.0-nullsafety.4 [meta path]
- firebase_core 0.5.2 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.1 [firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 2.0.0 [flutter path_provider uuid http path sqflite pedantic clock file rxdart]
- flutter_image 3.0.0 [flutter]
- flutter_local_notifications_platform_interface 2.0.0+1 [flutter plugin_platform_interface]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface]
- intl 0.17.0-nullsafety.2 [clock path]
- js 0.6.3-nullsafety.3
- json_annotation 3.1.0
- json_serializable 3.5.0 [analyzer build build_config json_annotation meta path source_gen]
- latlong 0.6.1 [logging console_log_handler validate intl]
- libphonenumber 1.0.2 [flutter meta]
- linkify 3.0.0
- lists 0.1.6
- location_platform_interface 1.0.1 [flutter meta plugin_platform_interface]
- location_web 1.0.0 [flutter flutter_web_plugins location_platform_interface http_parser meta js]
- logging 0.11.4
- matcher 0.12.10-nullsafety.3 [stack_trace]
- meta 1.3.0-nullsafety.6
- mgrs_dart 1.0.1 [unicode]
- node_interop 1.1.1 [js]
- node_io 1.1.1 [node_interop path]
- octo_image 0.3.0 [flutter flutter_blurhash]
- package_config 1.9.3 [path charcode]
- path 1.8.0-nullsafety.3
- path_provider 1.6.21 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+4 [flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+1 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- permission_handler_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- pin_input_text_field 3.1.1 [flutter]
- platform 3.0.0-nullsafety.4
- plugin_platform_interface 1.0.3 [meta]
- positioned_tap_detector 1.0.3 [flutter]
- process 4.0.0-nullsafety.4 [file path platform]
- proj4dart 1.0.5 [mgrs_dart wkt_parser meta]
- pub_semver 1.4.4 [collection]
- pubspec_parse 0.1.5 [checked_yaml json_annotation pub_semver yaml]
- quiver 2.1.3 [matcher meta]
- rxdart 0.24.1
- shared_preferences_linux 0.0.2+2 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+10 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.1+1 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows]
- sky_engine 0.0.99
- sliver_tools 0.1.9 [flutter]
- source_gen 0.9.7+1 [analyzer async build dart_style glob meta path pedantic source_span]
- source_span 1.8.0-nullsafety.4 [charcode collection path term_glyph]
- sqflite 1.3.1+2 [flutter sqflite_common path]
- sqflite_common 1.0.2+1 [synchronized path meta]
- stack_trace 1.10.0-nullsafety.6 [path]
- stream_channel 2.1.0-nullsafety.3 [async]
- string_scanner 1.1.0-nullsafety.3 [charcode source_span]
- synchronized 2.2.0+2
- term_glyph 1.2.0-nullsafety.3
- test_api 0.2.19-nullsafety.6 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timezone 0.5.9 [path]
- transparent_image 1.0.0
- tuple 1.0.3 [quiver]
- typed_data 1.3.0-nullsafety.5 [collection]
- unicode 0.2.4 [lists]
- url_launcher_linux 0.0.1+4 [flutter]
- url_launcher_macos 0.0.1+9 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.5+1 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+3 [flutter]
- validate 1.7.0
- vector_math 2.1.0-nullsafety.5
- watcher 0.9.7+15 [async path pedantic]
- win32 1.7.3 [ffi]
- wkt_parser 1.0.7
- xdg_directories 0.1.2 [meta path process]
- yaml 2.2.1 [charcode collection string_scanner source_span]

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact: deprecated-versionThis bug exists only in an older version and is no longer present in later releases.plugin: messagingtype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions