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.69k stars 3.97k forks source link

πŸ› [firebase_messaging] Production Crash with java.lang.NullPointerException #7329

Closed tattivitorino closed 2 years ago

tattivitorino commented 2 years ago

Bug report

Describe the bug Crashlytics reports (as below) appeared on my FB dashboard yesterday. My app is in production and everything was ok before. Does any of you have been experiencing these problems?

this version is still with targetSDK = 29 Android 11 - Galaxy A51

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.XXXXXXX.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3827)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4003)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2317)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8595)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
       at androidx.localbroadcastmanager.content.LocalBroadcastManager.a(LocalBroadcastManager.java:9)
       at io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin.a(FlutterFirebaseMessagingPlugin.java:31)
       at io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin.getExceptionDetails(FlutterFirebaseMessagingPlugin.java)
       at io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin.onAttachedToEngine(FlutterFirebaseMessagingPlugin.java:8)
       at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.a(FlutterEngineConnectionRegistry.java:79)
       at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:104)
       at XXXXX.MainActivity.configureFlutterEngine(MainActivity.java:5)
       at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.a(FlutterActivityAndFragmentDelegate.java:58)
       at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:13)
       at android.app.Activity.performCreate(Activity.java:8207)
       at android.app.Activity.performCreate(Activity.java:8191)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3800)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4003)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2317)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8595)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [βœ“] Flutter (Channel stable, 2.0.3, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-BR) [βœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.2) [βœ“] Xcode - develop for iOS and macOS [βœ“] Chrome - develop for the web [βœ“] Android Studio (version 4.0) [βœ“] VS Code (version 1.62.0) [βœ“] Connected device (3 available) ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.12.2 Flutter SDK 2.0.3 wlrealita 1.0.0+1 dependencies: - cupertino_icons 1.0.3 - evom_app 1.0.0+1 [config flutter qr_flutter http intl package_info provider progress_dialog mask_text_input_formatter url_launcher apple_sign_in firebase_core firebase_analytics firebase_crashlytics firebase_auth google_sign_in flutter_local_notifications firebase_messaging cupertino_icons flutter_secure_storage device_info screen flutter_localizations hidden_drawer_menu location flutter_flavor flutter_masked_text extended_masked_text clipboard_manager mockito dotted_border autocomplete_textfield connectivity gson brasil_fields image_picker path path_provider flutter_barcode_scanner google_maps_flutter freshchat_sdk font_awesome_flutter flutter_svg carousel_slider jwt_decode] - extended_masked_text 2.3.1 [flutter] - firebase_analytics 8.1.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta] - firebase_auth 1.2.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.2.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.0.4 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 10.0.0 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_barcode_scanner 2.0.0 [flutter flutter_plugin_android_lifecycle] - flutter_local_notifications 5.0.0+4 [flutter flutter_local_notifications_platform_interface platform timezone] - flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml] - font_awesome_flutter 9.1.0 [flutter] - freshchat_sdk 0.6.0 [flutter] - google_maps_flutter 2.0.5 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface] - google_sign_in 5.0.3 [google_sign_in_platform_interface google_sign_in_web flutter meta] - image_picker 0.7.5+2 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface image_picker_for_web] - jwt_decode 0.3.1 - location 4.1.1 [flutter location_platform_interface location_web meta] - path 1.8.0 - path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - splashscreen 1.3.5 [flutter] 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] dependency overrides: - config 1.0.0 transitive dependencies: - _fe_analyzer_shared 21.0.0 [meta] - analyzer 1.5.0 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml pedantic] - apple_sign_in 0.1.0 [flutter] - args 2.1.0 - async 2.5.0 [collection] - autocomplete_textfield 1.7.3 [flutter] - boolean_selector 2.1.0 [source_span string_scanner] - brasil_fields 1.1.2 [flutter intl pedantic] - build 2.0.1 [analyzer async convert crypto glob logging meta path] - built_collection 5.0.0 - built_value 8.0.6 [built_collection collection fixnum] - carousel_slider 4.0.0 [flutter] - characters 1.1.0 - charcode 1.2.0 - cli_util 0.3.0 [meta path] - clipboard_manager 0.0.4 [flutter] - clock 1.1.0 - code_builder 4.0.0 [built_collection built_value collection matcher meta] - collection 1.15.0 - colorize 2.0.0 - connectivity 3.0.4 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - connectivity_for_web 0.4.0 [connectivity_platform_interface flutter_web_plugins flutter] - connectivity_macos 0.2.0 [flutter] - connectivity_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - convert 3.0.0 [typed_data] - crypto 3.0.1 [collection typed_data] - dart_style 2.0.1 [analyzer args path pub_semver source_span] - device_info 2.0.1 [flutter device_info_platform_interface] - device_info_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - dotted_border 2.0.0 [flutter path_drawing] - fake_async 1.2.0 [clock collection] - ffi 1.0.0 - file 6.1.1 [meta path] - firebase 9.0.1 [http http_parser js] - firebase_analytics_platform_interface 2.0.1 [flutter meta] - firebase_analytics_web 0.3.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta] - firebase_auth_platform_interface 4.2.3 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 1.1.3 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.0.4 [collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 3.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.0.0 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - fixnum 1.0.0 - flutter_flavor 1.1.4 [flutter] - flutter_local_notifications_platform_interface 3.0.0 [flutter plugin_platform_interface] - flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math] - flutter_masked_text 0.8.0 [flutter] - flutter_plugin_android_lifecycle 2.0.1 [flutter] - flutter_secure_storage 4.2.0 [meta flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - glob 2.0.1 [async collection file path pedantic string_scanner] - google_maps_flutter_platform_interface 2.0.4 [flutter meta plugin_platform_interface stream_transform collection] - google_sign_in_platform_interface 2.0.1 [flutter meta quiver] - google_sign_in_web 0.10.0 [google_sign_in_platform_interface flutter flutter_web_plugins meta js] - gson 0.1.4 [colorize] - hidden_drawer_menu 2.0.1 [flutter] - http 0.13.3 [async http_parser meta path pedantic] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image_picker_for_web 2.0.0 [image_picker_platform_interface meta flutter flutter_web_plugins] - image_picker_platform_interface 2.1.0 [flutter meta http plugin_platform_interface] - intl 0.17.0 [clock path] - js 0.6.3 - location_platform_interface 2.1.0 [flutter meta plugin_platform_interface] - location_web 3.0.0 [flutter flutter_web_plugins http_parser js location_platform_interface meta] - logging 1.0.1 - mask_text_input_formatter 1.2.1 [flutter] - matcher 0.12.10 [stack_trace] - meta 1.3.0 - mockito 5.0.8 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api] - nested 1.0.0 [flutter] - package_config 2.0.0 [path] - package_info 2.0.0 [flutter] - path_drawing 0.5.1 [vector_math meta path_parsing flutter] - path_parsing 0.2.1 [vector_math meta] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.0 - petitparser 4.1.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - process 4.2.1 [file path platform] - progress_dialog 1.2.4 [flutter] - provider 5.0.0 [collection flutter nested] - pub_semver 2.0.0 [collection] - qr 2.0.0 [meta] - qr_flutter 4.0.0 [flutter qr] - quiver 3.0.1 [matcher] - screen 0.0.5 [flutter] - sky_engine 0.0.99 - source_gen 1.0.0 [analyzer async build dart_style glob meta path pedantic source_span] - source_span 1.8.0 [charcode collection path term_glyph] - 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] - term_glyph 1.2.0 - test_api 0.2.19 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.7.0 [path] - typed_data 1.3.0 [collection] - url_launcher 6.0.4 [flutter url_launcher_platform_interface url_launcher_linux url_launcher_macos url_launcher_windows url_launcher_web] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.0 [url_launcher_platform_interface meta flutter flutter_web_plugins] - url_launcher_windows 2.0.0 [flutter] - vector_math 2.1.0 - watcher 1.0.0 [async path pedantic] - win32 2.0.5 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.1.2 [collection meta petitparser] - yaml 3.1.0 [collection source_span string_scanner] ```

darshankawar commented 2 years ago

@tattivitorino A similar issue was fixed and merged recently on master: https://github.com/FirebaseExtended/flutterfire/pull/7088, but since you are on older version of stable, you will need to upgrade to latest master to see it working.

google-oss-bot commented 2 years ago

Hey @tattivitorino. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

tattivitorino commented 2 years ago

@darshankawar thx for you reply and I'm sorry for not responding before.. you mean upgrading firebase_messaging or flutter or both?

maheshj01 commented 2 years ago

@tattivitorino please try upgrading both plugin and the flutter sdk.

google-oss-bot commented 2 years ago

Hey @tattivitorino. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@tattivitorino if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.