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

安卓12安装Flutter APK报INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

问题背景

Android 12设备安装Flutter构建的APK时,弹出「There was a problem while parsing the package(解析软件包时出现问题)」提示,通过adb执行安装命令返回如下错误日志:

adb: failed to install C:\Users\***\Desktop\***\build\app\outputs\flutter-apk\app.apk: Failure     
[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl159430148.tmp/base.apk (at 
Binary XML file line #263): com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver: Targeting S+      
(version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

当前项目的AndroidManifest.xml完整内容如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ordeno">
         
   <application
        android:label="abcd"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <meta-data android:name="com.facebook.sdk.ApplicationId" 
        android:value="@string/facebook_app_id"/>
    
        <meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/>

        <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="**********" />


        <activity android:name="com.facebook.FacebookActivity"
            android:exported="true"
            android:configChanges=
                    "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />
        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </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">
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              /> 
              
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="sdk"
                    android:host="3ds.sdk.io" />
            </intent-filter>

            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>              
            </intent-filter>
            <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="dummy.page" />
                <data android:scheme="https" />
            </intent-filter>
        </activity>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />  
         <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/notification_icon"
            />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id"
            />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/default_color"
            />
    </application>
</manifest>

已经给所有<activity>标签添加了android:exported="true"属性,但仍然报相同错误,需要排查解决方法。

问题根因

Android 12(API 31及以上)的强制合规规则是:所有包含<intent-filter>的四大组件(Activity、Service、BroadcastReceiver、ContentProvider)都必须显式声明android:exported属性,不是只给Activity加配置就满足要求。
从错误日志可以直接定位问题点:出问题的组件是flutter_local_notifications插件自带的ScheduledNotificationBootReceiver广播接收器,这个组件的配置存放在插件自身的清单文件中,会在构建时自动合并到最终APK的清单里,你之前只修改主项目里自己写的Activity配置,完全没有覆盖到这个出问题的插件组件节点。

解决步骤
  • 优先升级插件版本:把flutter_local_notifications升级到最新稳定版,新版本已经原生适配Android 12规则,自带正确的android:exported配置,不会出现清单格式错误。执行如下命令升级:
    flutter pub upgrade flutter_local_notifications
    
    升级完成后执行flutter clean清除旧构建缓存,重新打包即可。
  • 无法升级插件时手动覆盖配置:如果因为项目兼容限制不能升级插件版本,直接在主项目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"/>
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
        </intent-filter>
    </receiver>
    
    注意这个接收器不需要被外部应用调用,exported属性设为false即可,不要设为true避免引入安全风险。
  • 全量排查其他依赖适配问题:Flutter构建时最终的清单文件是主工程配置+所有插件依赖的清单合并生成的,改完上述配置后,可以执行清单构建命令检查是否还有其他同类问题:
    进入项目的android目录执行:
    ./gradlew app:processDebugMainManifest
    
    构建完成后打开app/build/intermediates/merged_manifest/路径下的最终合并清单文件,全局搜索所有带<intent-filter>的节点,逐一确认是否配置了android:exported属性,避免其他第三方插件也存在未适配Android 12的问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.03 04:57:26