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

Flutter应用升级minSdkVersion至31后AndroidManifest合并失败

解决方案:为MainActivity添加android:exported属性

Android 12(API 31)及更高版本有强制要求:所有包含<intent-filter>的组件(Activity、Service、BroadcastReceiver)必须显式声明android:exported属性,你的MainActivity因为带有启动入口的intent filter,所以必须补上这个属性才能通过Manifest合并校验。

具体操作步骤:

  1. 打开项目中的android/app/src/main/AndroidManifest.xml文件
  2. 找到<activity#com.example.debt.MainActivity>标签,添加android:exported="true"(这是应用的启动入口,需要被系统Launcher调用,因此设为true)

修改后的Manifest代码示例:

<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>

额外注意事项:

  • 检查Manifest中其他组件:如果应用还有其他带有<intent-filter>的Activity、Service或BroadcastReceiver,同样需要为它们添加android:exported属性,取值根据组件用途决定(内部组件设为false,需要外部调用的设为true)
  • 修改完成后直接重新构建App Bundle即可,无需额外清除缓存

内容的提问来源于stack exchange,提问作者Niklas Müller

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 17:01:18