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

Flutter关联Firebase后运行报错:Manifest合并失败需指定android:exported

解决Flutter关联Firebase后Manifest合并失败问题

问题描述

关联Firebase后在模拟器运行Flutter应用时,出现任务:app:processDebugMainManifest执行失败,错误提示:

Manifest合并失败 : 需为元素<activity#com.example.flutter_application_1.MainActivity>显式指定android:exported。面向Android 12及更高版本的应用,当对应组件定义了intent filter时,必须为android:exported指定明确值。

解决方案

  1. 打开项目路径android/app/src/main/AndroidManifest.xml文件
  2. 找到包含intent-filter的MainActivity标签,添加android:exported="true"属性(主Activity作为应用入口,需允许外部访问)

修改后的示例代码:

<activity
    android:name=".MainActivity"
    android:exported="true"
    android:launchMode="singleTop"
    android:theme="@style/LaunchTheme"
    android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
    android:hardwareAccelerated="true"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>

原因说明

Android 12(API 31)及以上版本强化了组件权限管控:只要组件(Activity、Service等)声明了intent-filter,就必须显式设置android:exported属性。其中:

  • true表示允许其他应用启动或访问该组件
  • false表示仅允许应用内部访问该组件

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 08:42:24