Flutter迁移Android 11至12构建失败:已加android:exported仍报错
Android 11迁移至Android 12构建App Bundle失败的解决方案
问题说明
将Flutter项目从Android 11迁移到Android 12时,已完成以下操作:
- 修改
targetSdkVersion为31 - 在AndroidManifest.xml中为主组件添加
android:exported="true"属性
但执行bundleRelease构建App Bundle时,仍然出现Manifest合并错误。
错误日志
/Users/anhdinhhoangquang/mobicloud/android/app/src/main/AndroidManifest.xml:15:9-22:20 Error: android:exported needs to be explicitly specified for element <receiver#com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. ********************************************************* ********************************************************* FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processReleaseMainManifest'. > Manifest merger failed with multiple errors, see logs * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. BUILD FAILED in 6s Running Gradle task 'bundleRelease'... 6.9s Gradle task bundleRelease failed with exit code 1
解决步骤
在AndroidManifest.xml中,为报错的com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver接收器显式声明android:exported="true"属性:
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver" android:exported="true"> </receiver>
项目配置参考
当前build.gradle文件的defaultConfig配置如下:
defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.mobifone.mobicloud" minSdkVersion 21 targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true }
内容的提问来源于stack exchange,提问作者Quang Anh
相关产品推荐
相关产品推荐

