仅在 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/