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

React Native安卓应用安装失败:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

解决React Native应用真机安装报错INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

错误核心原因

从报错日志可直接定位问题:

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1629738225.tmp/base.apk (at Binary XML file line #75): androidx.media.session.MediaButtonReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present

你的应用目标SDK版本为Android 12(API 31)及以上,而androidx.media.session.MediaButtonReceiver这个广播接收器(由依赖库自动注入到Manifest中)未显式设置android:exported属性。Android 12+强制要求:所有带有intent-filter的组件(Activity、Service、BroadcastReceiver)必须明确指定android:exported为true或false,否则会触发安装解析失败。

解决方案

在你的AndroidManifest.xml的<application>标签内,显式声明该广播接收器并添加android:exported属性:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.myplayer">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.android.vending.BILLING" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <!-- 原有主Activity配置 -->
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        android:exported="true"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <!-- 新增MediaButtonReceiver声明 -->
      <receiver
          android:name="androidx.media.session.MediaButtonReceiver"
          android:exported="true">
          <intent-filter>
              <action android:name="android.intent.action.MEDIA_BUTTON" />
          </intent-filter>
      </receiver>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

可选方案(无需该接收器时)

如果你的应用不需要这个MediaButtonReceiver,可通过tools:node="remove"将其从Manifest中移除(需先在manifest根标签添加tools命名空间):

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  package="com.myplayer">

    <!-- ...其他权限和配置 -->

    <application>
        <!-- ...其他组件配置 -->
        <receiver
            android:name="androidx.media.session.MediaButtonReceiver"
            tools:node="remove" />
    </application>

</manifest>

验证修改

保存配置后,重新执行安装命令:

npx react-native run-android

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 10:12:55