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

Flutter项目部署至手机报错:需指定android:exported属性求解决方案

解决Flutter项目部署Android 12+设备时的android:exported错误

你的项目依赖的flutter_local_notifications插件中的ScheduledNotificationBootReceiver广播接收器未显式声明android:exported属性,而Android 12及以上系统要求所有包含intent filter的组件必须明确设置该属性,导致Manifest合并失败。以下是两种具体解决方法:

方法1:升级flutter_local_notifications插件到最新版本

  • 打开项目根目录的pubspec.yaml文件
  • 找到flutter_local_notifications依赖项,将版本号替换为最新稳定版(如^16.1.0,可根据插件官方最新版本调整)
  • 执行命令:flutter pub get更新依赖
  • 重新运行flutter run

方法2:手动在AndroidManifest.xml中添加属性

如果暂时不想升级插件,可手动修改配置:

  • 打开android/app/src/main/AndroidManifest.xml文件
  • 在application标签内添加如下代码,覆盖插件默认的接收器配置:
<receiver
    android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
    android:exported="false">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
    </intent-filter>
</receiver>
  • 保存文件后重新运行flutter run

注意:若后续出现其他组件(如Activity、其他广播接收器)的同类报错,需为对应组件同样添加android:exported属性——组件仅内部使用时设为false,需外部应用访问时设为true。

内容的提问来源于stack exchange,提问作者The-Kingsmen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 05:07:21