Firebase Cloud Messaging Keeps Crashing My App

Viewed 260

For about a week now I have been having so many problems with firebase cloud messaging. I just want the simplest feature of the firebase cloud messaging. I just want a notification to the users of my application. I had tried this for 3days over and over again. And it started working. It worked just once. The notification was sent to my mobile device. But after anytime a notification is sent to any device. It keeps crashing the application. The app says it keeps stopping. And things like that. I have put in all the proper SDKs. And have restarted so many times. Please I need help, anyone, please.

This is my Andriod manifest file (at least the part I can show)

  <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <service
           android:name=".java.MyFirebaseMessagingService"
           android:exported="false">
          <intent-filter>
              <action android:name="com.google.firebase.MESSAGING_EVENT" />
          </intent-filter>
        </service>

This is my app build.gradle (also the part related to firebase messaging)

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-messaging:20.2.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.android.gms:play-services-ads:19.1.0'
}

and my pubspec.yaml

name: boomm
description: A new Flutter project.

# 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.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_spinkit: ^4.1.2
  intl: ^0.16.1
  font_awesome_flutter: ^8.8.1
  curved_navigation_bar: ^0.3.2  
  firebase_auth: ^0.14.0+5
  cloud_firestore: ^0.13.6
  flutter_screenutil: ^0.4.2
  flutter_staggered_grid_view: "^0.3.0"
  firebase_storage: ^3.1.5
  photo_manager: ^0.5.1
  timeago: ^2.0.26
  geolocator: 5.0.1
  uuid: ^2.0.0
  provider: ^4.1.2
  image: ^2.0.7
  path_provider: ^0.5.0+1
  admob_flutter: "^0.3.4"
  firebase_messaging: ^6.0.16
  cached_network_image: 
  flutter_svg:


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # 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

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/images/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/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: Comic
      fonts:
        - asset: assets/fonts/ComicNeue-Regular.ttf
    - family: Lobster
      fonts:
        - asset: assets/fonts/Lobster-Regular.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages
0 Answers
Related