Firebase Messaging on Android suddenly started crashing when message received
Asked Answered
M

6

50

Currently using react native, react-native-firebase, and react-native-push-notification. Everything was fine until suddenly today firebase messaging started causing the app to crash. The error message is the following:

    Process: com.packagename, PID: 30087
    java.lang.AbstractMethodError: abstract method "com.google.android.gms.tasks.Task com.google.firebase.iid.WithinAppServiceBinder$IntentHandler.zza(android.content.Intent)"
        at com.google.firebase.iid.WithinAppServiceBinder.zza(com.google.firebase:firebase-iid@@20.2.2:9)
        at com.google.firebase.iid.zzaw.zza(com.google.firebase:firebase-iid@@20.2.2:30)
        at com.google.firebase.iid.zzaw.onServiceConnected(com.google.firebase:firebase-iid@@20.2.2:59)
        at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:2067)
        at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:2099)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8016)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

The error occurs when a notification is received, but does not trigger a data message. In addition, the notification is received and processed before causing the crash.

I thought the error might have been caused by changing the react-native-firebase/app version, so I reverted my project on git to that of a previous, working version. However, I still get the same error after cleaning and rebuilding. It also occurs even if there are no notification listeners set up on the react native side, although I'm not sure what that entails for the actual native code. What could possibly be the problem? I'm using versions of react-native-firebase/messaging (7.1.5) and react-native-firebase/app (7.2.0) that were previously functional.

Manassas answered 7/7, 2020 at 1:59 Comment(0)
G
39

We tried adding firebaseMessagingVersion = "20.2.1" into the ext section in the root project android/build.gradle which fixed it for us. We looked into the safeExtGet method and found that it would try to extract the top level variable from the root project file.

By doing it in this way we didn't need to touch the node modules.

ext {
        googlePlayServicesVersion = "16.+"
        firebaseVersion = "17.3.4"
        firebaseMessagingVersion = "20.2.1"
    }
Greiner answered 7/7, 2020 at 4:5 Comment(4)
This is what I ended up doing as well, will mark this as the correct answerManassas
I had the same issue and this saved my butt. Thank you!Mushro
Yeah, downgrading worked. Thank you for pointing this out.Rescission
Downgrading is the correct solution, see my answer below for more information.Snakeroot
S
45

Edit 07/09/2020: We have released firebase-iid and firebase-messaging versions 20.2.3 with a fix for this issue, please upgrade to the latest versions.


[Firebaser here] It looks like yesterday's releases of firebase-messaging and firebase-iid contain a bug which can cause this crash. We are working hard on a fix.

For now the best thing to do is to use the versions released on June 18th: https://firebase.google.com/support/release-notes/android#2020-06-18

  • com.google.firebase:firebase-messaging:20.2.1
  • com.google.firebase:firebase-iid:20.2.1

We are working on a fix and hope to have a new release out soon. When we do I will update this answer and the release notes will be available here: https://firebase.google.com/support/release-notes/android

Snakeroot answered 8/7, 2020 at 14:56 Comment(2)
Thanks for the update @sam-stern! I'm also having this issue, so please let us know whenever you have news 😄Bigener
Can the firebase Iid be set also with adding firebaseIidVersion = "20.2.1" to the android/build.gradle?Lexington
G
39

We tried adding firebaseMessagingVersion = "20.2.1" into the ext section in the root project android/build.gradle which fixed it for us. We looked into the safeExtGet method and found that it would try to extract the top level variable from the root project file.

By doing it in this way we didn't need to touch the node modules.

ext {
        googlePlayServicesVersion = "16.+"
        firebaseVersion = "17.3.4"
        firebaseMessagingVersion = "20.2.1"
    }
Greiner answered 7/7, 2020 at 4:5 Comment(4)
This is what I ended up doing as well, will mark this as the correct answerManassas
I had the same issue and this saved my butt. Thank you!Mushro
Yeah, downgrading worked. Thank you for pointing this out.Rescission
Downgrading is the correct solution, see my answer below for more information.Snakeroot
J
12

Exact same issue with these versions. And yes they were functional before this "@react-native-firebase/app": "^6.7.1", "@react-native-firebase/messaging": "^6.7.1",

Issue Solved:

  1. Go to react-native-push-notification/build.gradle
  2. Change def firebaseVersion = safeExtGet('firebaseVersion', '+') to def firebaseVersion = safeExtGet('firebaseVersion', '20.2.1')

It was picking us the version 20.2.2 which is not stable and was causing all kind of weird issues.

Jocelin answered 7/7, 2020 at 2:25 Comment(5)
wow this did it thanks so much! I was going insane because of this.Manassas
By the way for me it was firebaseMessagingVersion, in case anyone else sees this and has the same issueManassas
Thanks! @Manassas I had to do the same as you, implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '20.2.1')}"Magistrate
Wouldn't this just get wiped when you reinstall node modules? Also it wouldn't be committed to version control (assuming you'd git-ignore node_modules). I'm new to RN, maybe I'm misunderstanding something.Outleap
Yes it would get wiped, In this case I would recommend following the accepted answer but if you ever need to change anything in node_modules, patch-package is a convenient solutionManassas
F
5

This upgrade fixed the issue for me

implementation 'com.google.firebase:firebase-messaging:20.2.3'
Flesher answered 16/7, 2020 at 5:51 Comment(1)
This worked for me. Been scratching my head for 2 days.Spaceless
F
0

This case is working for me:

implementation "com.google.firebase:firebase-messaging:20.2.3"
implementation "com.google.firebase:firebase-analytics:17.4.4"

Ref to github issue

Fujio answered 17/7, 2020 at 19:55 Comment(0)
A
0

This issue is fixed with latest version of this dependency. https://firebase.google.com/support/release-notes/android#messaging_v20-2-3

Aprilette answered 21/7, 2020 at 1:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.