FCM:无法实例化接收器com.google.firebase.iid.FirebaseInstanceIdReceiver:

问题描述 投票:0回答:1

应用程序在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)
android firebase firebase-cloud-messaging android-8.0-oreo
1个回答
1
投票

使用书法图书馆时我遇到了同样的问题。即使在Firebase第一次请求令牌时安装后第一次崩溃。不仅接收推送通知。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.