升级Android 12遇INSTALL_PARSE_FAILED_MANIFEST_MALFORMED错误求助
Android 12 升级后INSTALL_PARSE_FAILED_MANIFEST_MALFORMED错误排查指引
核心排查方向(Android 12 特有要求)
1. 所有四大组件必须显式声明android:exported属性
Android 12(API 31)强制要求Activity、Service、BroadcastReceiver、ContentProvider这四类组件,无论是否配置intent-filter,都必须明确设置android:exported="true"或android:exported="false":
- 若组件需要被外部应用/系统调用(比如主Activity、可被外部启动的服务),设为
true; - 仅内部使用的组件,设为
false。
示例正确配置:
<!-- 主Activity(需被系统启动) --> <activity android:name=".MainActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- 内部服务 --> <service android:name=".core.MyInternalService" android:exported="false" />
2. 自定义权限的protectionLevel需符合规范
若清单中声明了自定义权限,需确保protectionLevel取值合法(仅能为normal、dangerous、signature、signatureOrSystem),且格式无拼写错误。错误示例:protectionLevel="sign"(应为signature)。
3. intent-filter配置错误
- 主Activity的
intent-filter必须包含<action android:name="android.intent.action.MAIN" />和<category android:name="android.intent.category.LAUNCHER" />,缺一不可; - 避免多个组件的
intent-filter出现冲突(比如重复的action导致系统无法识别启动入口)。
build.gradle 配置检查
- 确保
compileSdkVersion和targetSdkVersion均设为31; - Gradle插件版本需适配Android 12,建议使用
com.android.tools.build:gradle:7.0.0及以上版本(对应Gradle版本需为7.0及以上)。
快速排查步骤
- 全局搜索清单文件,确认所有四大组件都已添加
android:exported属性; - 检查自定义权限的
protectionLevel取值; - 验证主Activity的
intent-filter完整性; - 核对gradle插件与编译版本的兼容性。
内容的提问来源于stack exchange,提问作者Duliba Ionut
相关产品推荐
相关产品推荐

