android - FCM : Unable to instantiate receiver com. google.firebase.iid.FirebaseInstanceIdReceiver:

标签 android firebase firebase-cloud-messaging android-8.0-oreo

仅在 Oreo(8.0) 中接收推送通知时应用程序崩溃。

java.lang.RuntimeException: Unable to instantiate receiver com.google.firebase.iid.FirebaseInstanceIdReceiver: java.lang.ClassCastException: android.content.ContextWrapper cannot be cast to android.app.ContextImpl
        at android.app.ActivityThread.handleReceiver(ActivityThread.java:3236)
        at android.app.ActivityThread.-wrap17(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)

最佳答案

我在使用书法库时遇到了同样的问题。当 Firebase 第一次请求 token 时,它甚至在安装后第一次崩溃。不仅接收推送通知。

我的错误是我在 Application 类中重写 attachBaseContext 方法以返回 ContextWrapper 对象,但仅在 Activity 中需要。

因此,要恢复我的解决方案是删除 Application 类中的 attachBaseContext 并将其移动或只是将其放入 Activity 中。

关于android - FCM : Unable to instantiate receiver com. google.firebase.iid.FirebaseInstanceIdReceiver:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50392706/

相关文章:

java.io.EOFException :\n not found: limit=0 content=…

Android - JWplayer 全屏不工作问题

java - Google Play - onReceivedSslError

firebase - 如何在 Google Firebase 中区分 Android/IOS 的暂存/开发和生产构建以进行分析和崩溃

javascript - 如何获得FCM token ?

android - 如何删除不同应用程序相同 Activity 中的代码重复?

android - Firebase 云消息传递 : Expiration of FCM token

ios - 无法将 CLLocationDegrees 的值转换为预期参数 shopProperties

flutter : Strange behavior of Shared Preferences

ios - Firebase 消息传递仅适用于前台