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

Android12+应用报错:需为指定Receiver显式设置android:exported

解决Flutter Android 12+中ScheduledNotificationBootReceiver需显式指定android:exported的问题

问题描述

开发面向Android 12及更高版本的Flutter应用时,编译报错:

针对元素<receiver#com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver>,必须显式指定android:exported。

Android 12及以上版本强制要求:当组件(如Receiver)定义了intent-filter时,必须显式设置android:exported的布尔值,明确组件是否允许外部应用交互。

解决步骤

  1. 打开项目路径下的android/app/src/main/AndroidManifest.xml文件
  2. 在Manifest中添加或修改对应的<receiver>配置,显式声明android:exported属性:
    • 若接收器需要接收系统或外部应用的Intent(比如监听开机完成事件),设置android:exported="true"
    • 若仅用于应用内部交互,设置android:exported="false"
  3. 示例配置代码:
<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>

如果使用的是flutter_local_notifications库,也可以优先检查库版本是否已适配Android 12,但直接在本地Manifest中显式声明该属性是最直接的修复方式。

内容的提问来源于stack exchange,提问作者Louay Elaroui pro

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 10:31:19