收到消息时,Android 上的 Firebase 消息突然开始崩溃 [英] Firebase Messaging on Android suddenly started crashing when message received

查看:39
本文介绍了收到消息时,Android 上的 Firebase 消息突然开始崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前使用 react-native-firebase 和 react-native-push-notification.一切都很好,直到今天突然间 firebase 消息传递开始导致应用程序崩溃.错误信息如下:

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.

我认为错误可能是由更改 react-native-firebase/app 版本引起的,所以我将 git 上的项目恢复到以前的工作版本.但是,在清理和重建后,我仍然遇到相同的错误.即使在反应本机端没有设置通知侦听器,它也会发生,尽管我不确定实际本机代码需要什么.可能是什么问题?我正在使用以前可用的 react-native-firebase/messaging (7.1.5) 和 react-native-firebase/app (7.2.0) 版本.

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.

推荐答案

我们尝试将 firebaseMessagingVersion = "20.2.1" 添加到根项目 android/build.gradle 为我们修复了它.我们查看了 safeExtGet 方法,发现它会尝试从根项目文件中提取顶级变量.

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"
    }

这篇关于收到消息时,Android 上的 Firebase 消息突然开始崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆