firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.7k stars 3.97k forks source link

πŸ› [firebase_messaging] Crash #9312

Closed chejdj closed 2 years ago

chejdj commented 2 years ago

Bug report

Describe the bug A crash bug from FirebaseCrash platform

Steps to reproduce

No.

Expected behavior

No

Sample project

No


Additional context

Add any other context about the problem here. Crash log

Exception java.lang.RuntimeException: Unable to create service io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:4823)
  at android.app.ActivityThread.access$3000 (ActivityThread.java:260)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2470)
  at android.os.Handler.dispatchMessage (Handler.java:110)
  at android.os.Looper.loop (Looper.java:219)
  at android.app.ActivityThread.main (ActivityThread.java:8668)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1109)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference
  at io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundExecutor.getPluginCallbackHandle (FlutterFirebaseMessagingBackgroundExecutor.java:275)
  at io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundExecutor.startBackgroundIsolate (FlutterFirebaseMessagingBackgroundExecutor.java:116)
  at io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService.onCreate (FlutterFirebaseMessagingBackgroundService.java:106)
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:4809)

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [βœ“] Flutter (Channel unknown, 3.0.5, on macOS 12.1 21C52 darwin-x64, locale zh-Hans-CN) [βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4) [βœ“] Xcode - develop for iOS and macOS (Xcode 13.2.1) [βœ“] Chrome - develop for the web [βœ“] Android Studio (version 2021.2) [βœ“] IntelliJ IDEA Ultimate Edition (version 2022.2) [βœ“] VS Code (version 1.70.0) [βœ“] Connected device (2 available) [βœ“] HTTP Host Availability ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.17.6 Flutter SDK 3.0.5 connectapp 1.0.0+1 dependencies: - async 2.8.2 [collection meta] - awsome_video_player 0.0.1 [flutter video_player visibility_detector orientation connectivity flutter_screen_wake] - azlistview 2.0.0 [flutter scrollable_positioned_list] - bot_toast 4.0.3 [flutter] - characters 1.2.0 - chewie 1.2.2 [cupertino_icons flutter provider video_player wakelock] - connectivity_for_web 0.4.0+1 [connectivity_platform_interface flutter_web_plugins flutter] - crypto 3.0.2 [typed_data] - cupertino_icons 1.0.5 - device_info 2.0.3 [flutter device_info_platform_interface] - event_bus 2.0.0 - file_picker 4.6.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32] - firebase_core 1.20.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.8.6 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 11.4.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_performance 0.8.2+1 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter] - firebase_remote_config 2.0.13 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter] - fluro 2.0.3 [flutter] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_animator 3.2.2 [flutter vector_math] - flutter_cupertino_localizations 1.0.1 [flutter flutter_localizations] - flutter_datetime_picker 1.5.1 [flutter] - flutter_dotenv 5.0.2 [flutter] - flutter_easyrefresh 2.2.2 [flutter] - flutter_genius_scan 4.5.2 [flutter] - flutter_image_compress 1.1.1 [flutter] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math] - flutter_rating_bar 4.0.1 [flutter] - flutter_staggered_grid_view 0.4.1 [flutter] - flutter_swiper_null_safety 1.0.2 [flutter] - flutter_widget_from_html_core 0.8.5+3 [csslib flutter fwfh_text_style html] - fluttertoast 8.0.9 [flutter flutter_web_plugins] - get 4.6.5 [flutter] - heic_to_jpg 0.2.0 [flutter] - html 0.15.0 [csslib source_span] - image_gallery_saver 1.7.1 [flutter] - intl 0.17.0 [clock path] - json_annotation 4.6.0 [meta] - la_liveroom 0.0.1 [flutter] - la_multi_media_picker 0.0.3 [flutter] - la_route 0.0.1 [flutter package_info] - la_theme 0.0.4 [flutter] - la_unity 0.0.1 [flutter] - lingoace_package_account 0.0.1 [flutter lingoace_package_net json_annotation lingoace_package_sp_cache lingoace_package_log] - lingoace_package_ad_analysis 0.0.1 [flutter appsflyer_sdk] - lingoace_package_analytics 0.0.5 [flutter firebase_analytics amplitude_flutter flutter_plugin_track] - lingoace_package_cached_network_image 0.0.1 [flutter octo_image lingoace_package_cache_manager] - lingoace_package_cartoon 0.0.1 [flutter uuid dio permission_handler webview_flutter lingoace_package_log] - lingoace_package_log 0.0.1 [flutter lingoace_plugin_logan] - lingoace_package_net 0.0.1 [flutter dio bot_toast device_info_plus package_info_plus quiver] - lingoace_package_pdf 0.0.3 [flutter pdf printing lingoace_package_cache_manager flutter_pdfview flutter_pdf_printer numberpicker] - lingoace_package_sp_cache 0.0.1 [flutter shared_preferences] - lingoace_package_webview 0.0.1 [flutter webview_flutter lingoace_package_log connectivity] - linked_scroll_controller 0.2.0 [flutter] - lpinyin 2.0.3 - markdown 5.0.0 [args charcode meta] - month_picker_dialog 0.4.0 [flutter flutter_localizations intl rxdart] - network_to_file_image 3.1.0 [flutter] - notification_permissions 0.6.1 [flutter] - orientation 1.3.0 [flutter] - package_info 2.0.2 [flutter] - path 1.8.1 - path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - permission_handler 9.2.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - provider 5.0.0 [collection flutter nested] - qr_flutter 4.0.0 [flutter qr] - rich_text_widget 0.2.7 [flutter] - sprintf 6.0.0 - stripe_payment 1.1.3 [flutter] - underline_indicator 0.0.4 [flutter] - upload_manager 0.0.1 [flutter dio event_bus] - url_launcher 6.1.5 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - video_compress 3.1.1 [flutter] - visibility_detector 0.2.2 [flutter] dev dependencies: - build_runner 2.2.0 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - flutter_section_table_view 1.0.4 [flutter] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - json_serializable 6.3.1 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] transitive dependencies: - _fe_analyzer_shared 43.0.0 [meta] - amplitude_flutter 3.10.0 [flutter flutter_web_plugins js] - analyzer 4.3.1 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - appsflyer_sdk 6.5.2+2 [flutter] - archive 3.3.1 [crypto path] - args 2.3.1 - barcode 2.1.0 [meta qr] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.3.0 [analyzer async convert crypto glob logging meta path] - build_config 1.1.0 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.1.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.9 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.3 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.4.0 [built_collection collection fixnum meta] - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - clock 1.1.0 - code_builder 4.2.0 [built_collection built_value collection matcher meta] - collection 1.16.0 - connectivity 3.0.6 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - connectivity_macos 0.2.1+2 [flutter connectivity_platform_interface] - connectivity_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - convert 3.0.2 [typed_data] - csslib 0.17.2 [source_span] - dart_style 2.2.3 [analyzer args path pub_semver source_span] - device_info_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - device_info_plus 3.2.4 [flutter device_info_plus_platform_interface device_info_plus_macos device_info_plus_linux device_info_plus_web device_info_plus_windows] - device_info_plus_linux 2.1.1 [device_info_plus_platform_interface file flutter meta] - device_info_plus_macos 2.2.3 [device_info_plus_platform_interface flutter] - device_info_plus_platform_interface 2.3.0+1 [flutter meta plugin_platform_interface] - device_info_plus_web 2.1.0 [device_info_plus_platform_interface flutter_web_plugins flutter] - device_info_plus_windows 2.1.1 [device_info_plus_platform_interface ffi flutter win32] - dio 4.0.6 [http_parser path] - dio_http2_adapter 2.0.0 [http2 dio] - fake_async 1.3.0 [clock collection] - ffi 1.2.1 - file 6.1.2 [meta path] - firebase 9.0.3 [http http_parser js] - firebase_analytics 9.3.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_analytics_platform_interface 3.3.0 [firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.4.2 [firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_core_platform_interface 4.5.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 1.7.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.2.12 [collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 3.5.4 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.4.4 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_performance_platform_interface 0.1.1+12 [firebase_core flutter plugin_platform_interface] - firebase_performance_web 0.1.1+1 [firebase firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins js] - firebase_remote_config_platform_interface 1.1.12 [firebase_core flutter meta plugin_platform_interface] - firebase_remote_config_web 1.1.1 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js] - fixnum 1.0.1 - flutter_blurhash 0.7.0 [flutter] - flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_pdf_printer 1.0.0+2 [flutter] - flutter_pdfview 1.2.3 [flutter] - flutter_plugin_android_lifecycle 2.0.7 [flutter] - flutter_plugin_track 0.0.1 [flutter device_info shared_preferences la_net la_evereport] - flutter_screen_wake 1.0.2 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - frontend_server_client 2.1.3 [async path] - fwfh_text_style 2.22.08 [flutter] - glob 2.1.0 [async collection file path string_scanner] - graphs 2.1.0 [collection] - http 0.13.5 [async http_parser meta path] - http2 2.0.0 - http_multi_server 3.2.1 [async] - http_parser 4.0.1 [collection source_span string_scanner typed_data] - image 3.1.3 [archive meta xml] - infinite_listview 1.1.0 [flutter] - io 1.0.3 [meta path string_scanner] - js 0.6.4 - la_evereport 0.0.1 [flutter flutter_cupertino_localizations path_provider shared_preferences] - la_net 0.0.2 [flutter dio dio_http2_adapter] - lingoace_package_cache_manager 0.0.1 [flutter flutter_cache_manager file] - lingoace_plugin_logan 1.0.2 [flutter] - logging 1.0.2 - matcher 0.12.11 [stack_trace] - material_color_utilities 0.1.4 - meta 1.7.0 - mime 1.0.2 - nested 1.0.0 [flutter] - numberpicker 2.1.1 [flutter infinite_listview] - octo_image 1.0.2 [flutter flutter_blurhash] - package_config 2.1.0 [path] - package_info_plus 1.4.2 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] - package_info_plus_linux 1.0.5 [package_info_plus_platform_interface flutter path] - package_info_plus_macos 1.3.0 [flutter] - package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface] - package_info_plus_web 1.0.5 [flutter flutter_web_plugins http meta package_info_plus_platform_interface] - package_info_plus_windows 1.0.5 [package_info_plus_platform_interface ffi flutter win32] - path_parsing 0.2.1 [vector_math meta] - path_provider_android 2.0.17 [flutter path_provider_platform_interface] - path_provider_ios 2.0.11 [flutter path_provider_platform_interface] - path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.6 [flutter path_provider_platform_interface] - path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface] - path_provider_windows 2.0.7 [ffi flutter path path_provider_platform_interface win32] - pdf 3.6.4 [archive barcode crypto image meta path_parsing vector_math xml] - pedantic 1.11.1 - permission_handler_android 9.0.2+1 [flutter permission_handler_platform_interface] - permission_handler_apple 9.0.4 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.7.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.0 [flutter permission_handler_platform_interface] - petitparser 5.0.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.2 [meta] - pool 1.5.1 [async stack_trace] - printing 5.6.5 [ffi flutter flutter_web_plugins http image js meta pdf plugin_platform_interface] - process 4.2.4 [file path platform] - pub_semver 2.1.1 [collection meta] - pubspec_parse 1.2.0 [checked_yaml collection json_annotation pub_semver yaml] - qr 2.1.0 [meta] - quiver 3.1.0 [matcher] - rxdart 0.26.0 - scrollable_positioned_list 0.2.3 [flutter collection] - shared_preferences 2.0.7 [flutter meta shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - shared_preferences_linux 2.1.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_macos 2.0.4 [flutter shared_preferences_platform_interface] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.1.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.3.2 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.2 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_gen 1.2.2 [analyzer async build dart_style glob meta path source_span yaml] - source_helper 1.3.2 [analyzer collection source_gen] - source_span 1.8.2 [collection path term_glyph] - sqflite 2.0.3 [flutter sqflite_common path] - sqflite_common 2.2.1+1 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - synchronized 3.0.0+2 - term_glyph 1.2.0 - test_api 0.4.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timing 1.0.0 [json_annotation] - typed_data 1.3.1 [collection] - url_launcher_android 6.0.17 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.0 [flutter plugin_platform_interface] - url_launcher_web 2.0.12 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface] - uuid 3.0.6 [crypto] - vector_math 2.1.2 - video_player 2.4.5 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] - video_player_android 2.3.8 [flutter video_player_platform_interface] - video_player_avfoundation 2.3.5 [flutter video_player_platform_interface] - video_player_platform_interface 5.1.3 [flutter plugin_platform_interface] - video_player_web 2.0.12 [flutter flutter_web_plugins video_player_platform_interface] - wakelock 0.5.6 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows] - wakelock_macos 0.4.0 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.3.0 [flutter meta] - wakelock_web 0.4.0 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.2.0 [flutter wakelock_platform_interface win32] - watcher 1.0.1 [async path] - web_socket_channel 2.2.0 [async crypto stream_channel] - webview_flutter 2.0.13 [flutter] - win32 2.6.1 [ffi] - xdg_directories 0.2.0+1 [meta path process] - xml 5.4.1 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```

darshankawar commented 2 years ago

@chejdj Is this crash replicable locally in debug mode ? If so, can you provide steps to replicate and possibly minimal code sample ?

Also, can you try to upgrade firebase_messaging plugin and shared_preferences plugin to latest versions and try again to see if you still get same crash ?

https://pub.dev/packages/firebase_messaging/changelog#1201

https://pub.dev/packages/shared_preferences/changelog#2015

chejdj commented 2 years ago

@darshankawar OK,I can't replicate locally. I will update the latest version. If still exists, I will reopen