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.63k stars 3.95k forks source link

Firebase Firestore Null Pointer Exception #4171

Closed DeanPack closed 3 years ago

DeanPack commented 3 years ago

This bug has come up in our crashlytics for android users on our new version and is crashing their app. There are other threads for this exact issue, but they keep getting closed without any resolution. for example: https://github.com/FirebaseExtended/flutterfire/issues/2390 some people are saying going to firebase firestore version 0.13.4 fixes the issue, but we didn't start seeing this issue until we upgraded to firebase firestore 0.14.1+1 from 0.14.0+2 This isn't a new app, we've been using Flutter and FlutterFire packages since April of 2019. We recently updated our flutter from 1.17 to 1.22 and upgraded some of our plugins as well.

Unfortunately me and the other engineers on my team could not replicate the crashes, but the crashlytics error is right here:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
       at io.flutter.plugins.firebase.firestore.FlutterFirebaseFirestorePlugin.a(FlutterFirebaseFirestorePlugin.java:67)
       at io.flutter.plugins.firebase.firestore.-$$Lambda$FlutterFirebaseFirestorePlugin$TkTiyB-AIynA_CQ6V9vWC2Jw39c.onEvent(-.java:6)
       at com.google.firebase.firestore.DocumentReference.a(DocumentReference.java:87)
       at com.google.firebase.firestore.DocumentReference$$Lambda$3.a(DocumentReference.java:6)
       at com.google.firebase.firestore.core.AsyncEventListener.a(AsyncEventListener.java:6)
       at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(AsyncEventListener.java:6)
       at android.os.Handler.handleCallback(Handler.java:794)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at com.google.android.gms.internal.tasks.zzb.dispatchMessage(zzb.java)
       at android.os.Looper.loop(Looper.java:176)
       at android.app.ActivityThread.main(ActivityThread.java:6651)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

Flutter Doctor:

[✓] Flutter (Channel stable, 1.22.4, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-US)
    • Flutter version 1.22.4 at /Users/hallo/Documents/dev/flutter
    • Framework revision 1aafb3a8b9 (7 days ago), 2020-11-13 09:59:28 -0800
    • Engine revision 2c956a31c0
    • Dart version 2.10.4

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/hallo/Library/Android/sdk
    • Platform android-30, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.10.0

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 39.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.51.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (1 available)
    • SM G950U (mobile) • 988964414852304334 • android-arm64 • Android 9 (API 28)

• No issues found!

pubspec.yaml:

name: hallo
description: Practice English with friends.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
# version: 1.0.0+1
environment:
  sdk: ">=2.3.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  audio_recorder:
    git: https://github.com/sujindra-kodiary/audio_recorder
  audioplayer:
    git: https://github.com/halloglobal/audioplayer
  facebook_standard_events:
    git: https://github.com/halloglobal/facebook_standard_events.git
  flutter_keyboard_visibility:
    git: https://github.com/halloglobal/flutter_keyboard_visibility
  flutter_native_image:
    git:
      url: https://github.com/btastic/flutter_native_image.git
      ref: f4d9b4fadfb199cfbd75cabc8a1ac31a7bf43de5
  image_downloader:
    git: https://github.com/halloglobal/image_downloader
  save_in_gallery:
    git: https://github.com/sujindra-kodiary/save_in_gallery
  agora_rtc_engine: 3.1.3
  app_review: ^2.0.1
  apple_sign_in: ^0.1.0
  built_collection: ">=2.0.0 <5.0.0"
  built_value: ^7.1.0
  camera: ^0.5.8+11
  carousel_slider: ^2.2.1
  chewie: ^0.10.4
  cloud_firestore: 0.14.1+1
  cloud_functions: 0.7.0+1
  connectivity: ^2.0.0
  contacts_service: ^0.4.6
  cupertino_icons: ^1.0.0
  devicelocale: ^0.3.1
  dots_indicator: ^1.2.0
  downloads_path_provider: ^0.1.0
  dynamic_theme: ^1.0.1
  file_picker: ^2.0.12
  firebase_analytics: ^6.2.0
  firebase_auth: 0.18.3
  firebase_core: ^0.5.2
  firebase_database: ^4.3.0
  firebase_dynamic_links: ^0.6.2
  firebase_messaging: ^7.0.3
  firebase_remote_config: ^0.4.2
  firebase_storage: ^5.0.0
  flutter_app_badger: ^1.1.2
  flutter_colorpicker: ^0.3.2
  flutter_cupertino_date_picker:
    git: https://github.com/daveleenew/flutter-cupertino-date-picker.git
  flutter_cupertino_localizations: ^1.0.1
  flutter_linkify: ^4.0.2
  flutter_parsed_text: ^1.2.3
  flutter_redux: ^0.7.0
  flutter_slidable: ^0.5.4
  flutter_sms: 2.1.1
  flutter_svg: ^0.19.1
  flutter_time_picker_spinner: ^1.0.6+1
  flutter_webview_plugin: ^0.3.10+1
  fluttertoast: ^7.1.1
  geolocator: ^6.1.6
  geocoding: ^1.0.5
  get_ip: ^0.4.0
  google_sign_in: ^4.3.0
  http: ^0.12.0+4
  image_cropper: ^1.3.1
  image_picker: ^0.6.7+11
  in_app_purchase: ^0.3.4
  intl: ^0.16.0
  overlay_support: ^1.0.1
  package_info: ^0.4.0+3
  path_provider: ^1.6.18
  permission_handler: ^5.0.1+1
  photo_view: ^0.10.0
  provider: ^4.3.1
  redux: ^4.0.0
  redux_dev_tools: ^0.5.0
  redux_epics: ^0.14.0
  redux_logging: ^0.4.0
  redux_thunk: ^0.3.0
  rxdart: ^0.24.0
  scoped_model: ^1.0.1
  sentry: ^3.0.1
  share: ^0.6.0+1
  shimmer: ^1.1.1
  showcaseview: ^0.1.3
  simple_pdf_viewer: ^0.2.2
  streaming_shared_preferences: ^1.0.1
  stripe_payment: ^1.0.0
  timeago: ^2.0.9
  trust_fall: ^1.0.4
  url_launcher: ^5.0.2
  uuid: ^2.2.0
  vibration: ^1.7.2
  video_player: ^1.0.0
  wakelock: ^0.2.0
  web_socket_channel: ^1.0.8
  native_screenshot: 
    git: 
      url: https://gitlab.com/sujindra2014/native_screenshot
      ref: b271cbbdc1b8698dadfb0773b840ccc8bdf52c6e
  cached_network_image: ^2.3.0
  firebase_crashlytics: ^0.2.3
dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^1.10.0
  # test: ^1.5.1
  built_value_generator: ^7.1.0
  flutter_launcher_icons: ^0.7.0
  intl_translation: ^0.17.0

flutter_icons:
  adaptive_icon_background: "#ffffff"
  android: true
  ios: true
  image_path_android: "assets/app_icon.png"
  image_path_ios: "assets/app_icon.png"
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
  assets:
    - assets/nav/
    - assets/flags/
    - assets/icons/
    - assets/icons/2x/
    - assets/icons/3x/
    - assets/instamatch/
    - assets/logos/
    - assets/onboarding/
    - assets/profile/
    - assets/social/
    - assets/gamification/
    - assets/

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.
  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages
  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: Quicksand
      fonts:
        - asset: assets/fonts/Quicksand-Light.ttf
          weight: 300
        - asset: assets/fonts/Quicksand-Regular.ttf
          weight: 400
        - asset: assets/fonts/Quicksand-Medium.ttf
          weight: 500
        - asset: assets/fonts/Quicksand-SemiBold.ttf
          weight: 600
        - asset: assets/fonts/Quicksand-Bold.ttf
          weight: 700
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.io/custom-fonts/#from-packages
talent-apps commented 3 years ago

The same crash started occurring in our production app after upgrading cloud_firestore from 0.14.0+2 to 0.14.1+2 See https://github.com/FirebaseExtended/flutterfire/issues/4180

markusaksli-nc commented 3 years ago

Hi @DeanPack I see there's an open issue addressing the case you described https://github.com/FirebaseExtended/flutterfire/issues/3507. Please follow up on that issue, I'm closing the current one as a duplicate. If you disagree, please write in the comments and I will reopen it. Thank you