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

Android 12+安装失败:未设置android:exported属性求助

Android 12+ 安装失败修复:未设置android:exported及编译版本问题

问题根源

你的应用在Android 12及以上版本无法安装,核心原因有两个:

  • 部分带有intent-filter的组件未声明android:exported属性,违反Android 12的强制要求
  • 应用的compileSdkVersion仍为23(Android 6.0),未适配Android 12的编译规范

已完成的组件修复(更新后Manifest)

你已经对以下带intent-filter的组件补全了android:exported属性:

  • com.easternit.ec.MainActivity:设为android:exported="true"(启动页需系统外部调用)
  • com.gae.scaffolder.plugin.MyFirebaseMessagingService:设为android:exported="false"(仅内部接收Firebase消息事件)
  • com.gae.scaffolder.plugin.MyFirebaseInstanceIDService:设为android:exported="true"(需接收Firebase实例ID更新事件)
  • com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver:设为android:exported="false"(仅内部处理应用安装来源)

剩余关键问题:编译版本过低

你的Manifest中compileSdkVersion和platformBuildVersionCode仍停留在23,这不符合Android 12的适配要求。Android 12强制要求应用的compileSdkVersion至少为31,否则即使组件属性配置正确,也会触发安装校验失败。

最终修复方案

1. 升级编译版本配置

修改Manifest中的编译版本参数:

android:compileSdkVersion="31"
android:compileSdkVersionCodename="12"
platformBuildVersionCode="31"
platformBuildVersionName="12"

同时同步升级项目build.gradle文件中的compileSdkVersion、targetSdkVersion到31及以上。

2. 完整修复后的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    android:compileSdkVersion="31" 
    android:compileSdkVersionCodename="12" 
    android:hardwareAccelerated="true" 
    package="com.easternit.ec" 
    platformBuildVersionCode="31" 
    platformBuildVersionName="12">

    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

    <permission android:name="com.easternit.ec.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
    <uses-permission android:name="com.easternit.ec.permission.C2D_MESSAGE"/>

    <application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true">
        <activity android:configChanges="keyboard|keyboardHidden|locale|orientation|screenSize" android:exported="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="com.easternit.ec.MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <provider android:authorities="com.easternit.ec.DocumentViewerPlugin.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="de.sitewaerts.cordova.documentviewer.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/documentviewer_file_paths"/>
        </provider>

        <activity android:exported="true" android:launchMode="singleTop" android:name="com.gae.scaffolder.plugin.FCMPluginActivity">
            <intent-filter>
                <action android:name="FCM_PLUGIN_ACTIVITY"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>

        <service android:exported="false" android:name="com.gae.scaffolder.plugin.MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

        <service android:exported="true" android:name="com.gae.scaffolder.plugin.MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>

        <provider android:authorities="com.easternit.ec.opener.provider" android:exported="false" android:grantUriPermissions="true" android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/opener_paths"/>
        </provider>

        <service android:exported="true" android:name="com.google.firebase.messaging.FirebaseMessagingService">
            <intent-filter android:priority="-500">
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

        <receiver android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementReceiver"/>

        <receiver android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver" android:permission="android.permission.INSTALL_PACKAGES">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER"/>
            </intent-filter>
        </receiver>

        <service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementService"/>

        <receiver android:exported="true" android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <category android:name="com.easternit.ec"/>
            </intent-filter>
        </receiver>

        <receiver android:exported="false" android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"/>

        <service android:exported="true" android:name="com.google.firebase.iid.FirebaseInstanceIdService">
            <intent-filter android:priority="-500">
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>

        <provider android:authorities="com.easternit.ec.firebaseinitprovider" android:exported="false" android:initOrder="100" android:name="com.google.firebase.provider.FirebaseInitProvider"/>

        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
    </application>
</manifest>

3. 额外适配注意事项

  • 升级编译版本后,需补充适配Android 12及以上的新权限(如POST_NOTIFICATIONS通知权限)
  • 确保所有第三方插件(如Cordova插件)已更新至支持Android 12的版本,避免插件内部Manifest未适配引发的隐性问题

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 17:29:52