You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Oreo(8.0)设备接收FCM推送时崩溃:无法实例化FirebaseInstanceIdReceiver

Fix: FCM Crash on Oreo (8.0) - Unable to instantiate FirebaseInstanceIdReceiver

That ClassCastException when trying to instantiate FirebaseInstanceIdReceiver is a super common issue on Android 8.0, and it almost always ties back to either outdated FCM SDK versions or misconfigured manifest entries that clash with Oreo's strict broadcast receiver rules. Let's break down the fixes that have worked for most devs:

1. Upgrade your FCM SDK to an Oreo-compatible version

Older FCM releases didn't account for Oreo's context handling changes. You'll want to bump your Firebase Messaging dependency to at least version 17.0.0 (or the latest stable release) to get the necessary fixes. Update your module-level build.gradle:

implementation 'com.google.firebase:firebase-messaging:23.0.0' // Use the latest stable version here
// Make sure all other Firebase dependencies (like auth, firestore) match this version to avoid conflicts

2. Remove manual FirebaseInstanceIdReceiver declarations from your manifest

If you added the FirebaseInstanceIdReceiver to your AndroidManifest.xml manually, delete that entry immediately. The FCM SDK automatically injects the correct receiver configuration via manifest merging, and your manual declaration will cause context casting issues on Oreo. Here's what you need to remove:

<receiver
    android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
    android:exported="true"
    android:permission="com.google.android.c2dm.permission.SEND">
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
</receiver>

3. Ensure your push messages use high priority (server-side)

Oreo restricted background broadcasts, but FCM high-priority messages can bypass this limitation to wake your app. On your server side, set the message priority to high when sending pushes to Oreo devices. This ensures the system delivers the message and allows the receiver to instantiate correctly.

4. Clean and rebuild your project

Sometimes cached build files can cause weird compatibility glitches. Do a full clean to wipe old artifacts:

  • Go to Build > Clean Project in Android Studio
  • Then run Build > Rebuild Project
  • For good measure, you can also delete the .gradle and build folders in your project root before rebuilding

After applying these steps, reinstall the app on an Oreo test device and send a test push—this should resolve the instantiation crash.

内容的提问来源于stack exchange,提问作者Supz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:08:16