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

Flutter集成flutter_local_notifications与FCM时AndroidManifest编译报错

解决flutter_local_notifications针对Android 12+的exported属性编译错误

你之前把android:exported加在MainActivity上是没用的,错误提示里的ScheduledNotificationBootReceiver是flutter_local_notifications库自带的广播接收器,需要给这个组件单独设置exported属性,步骤如下:

  1. 打开项目的android/app/src/main/AndroidManifest.xml文件
  2. 找到或添加ScheduledNotificationBootReceiver的声明,显式指定android:exported属性:
<receiver
    android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
    </intent-filter>
</receiver>
  1. 同时,为了避免其他潜在编译错误,建议给同库的ScheduledNotificationReceiver也添加exported属性:
<receiver
    android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver"
    android:exported="false"/>

注意:

  • android:exported="true"是因为该接收器需要监听系统发出的开机完成广播,必须允许接收外部广播
  • 如果你的flutter_local_notifications版本较旧,建议先升级到最新稳定版,新版本可能已经默认配置了该属性,无需手动添加

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 13:01:11