Flutter构建报错:需为flutterlocalnotifications接收器指定android:exported
解决Flutter项目Gradle构建失败:ScheduledNotificationBootReceiver需指定android:exported属性
这个接收器是flutter_local_notifications插件自带的,会在Gradle构建时自动合并到你的项目主AndroidManifest.xml中,所以你自己的Manifest里看不到它。要解决这个问题,你需要在**自己项目的AndroidManifest.xml**中显式声明这个接收器并指定android:exported属性,具体操作如下:
- 打开项目中
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>
这里设置android:exported="false"是因为该接收器仅处理应用内部的系统启动广播,不需要对外暴露给其他应用。添加后重新运行项目,Gradle构建失败的问题应该就能解决。
内容的提问来源于stack exchange,提问作者Sunil Thapa
相关产品推荐
相关产品推荐

