FCM:无法实例化接收器com.google.firebase.iid.FirebaseInstanceIdReceiver: [英] FCM : Unable to instantiate receiver com.google.firebase.iid.FirebaseInstanceIdReceiver:
问题描述
仅在Oreo(8.0)中接收推送通知时,应用程序崩溃.
App is crashing while receiving push notification in Oreo(8.0) only .
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首次请求令牌时,即使在安装后第一次崩溃.不仅会收到推送通知.
I was facing the same issue when using Calligraphy library. Even it was crashing the first time after installing when Firebase requests a token for the first time. Not only receiving push notifications.
我的错误是我正在重写Application类中的attachBaseContext方法以返回ContextWrapper对象,但仅在Activity中需要.
My error was I was overriding attachBaseContext method in my Application class to return a ContextWrapper object, but was only needed in Activities.
因此,恢复我的解决方案是在Application类中删除attachBaseContext并将其移动或仅将其放入活动中.
So to resume my solution is to remove attachBaseContext in Application class and move it or just place it into activities.
这篇关于FCM:无法实例化接收器com.google.firebase.iid.FirebaseInstanceIdReceiver:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!