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

无人久伴 提交于 2019-12-10 11:59:46

问题


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)

回答1:


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.

My error was I was overriding attachBaseContext method in my Application class to return a ContextWrapper object, but was only needed in Activities.

So to resume my solution is to remove attachBaseContext in Application class and move it or just place it into activities.




回答2:


This might help; add these to your proguard if you are using it!

-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-keep class com.google.firebase.** { *; }


来源:https://stackoverflow.com/questions/50392706/fcm-unable-to-instantiate-receiver-com-google-firebase-iid-firebaseinstanceidr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!