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

Android 12+适配报错:需为VRPurchaseActivity指定android:exported属性

解决AndroidManifest合并错误:添加android:exported属性

错误说明

错误:元素<activity#com.unity.purchasing.googleplay.VRPurchaseActivity>需显式指定android:exported属性。针对Android 12及更高版本的应用,当对应组件定义了intent filter时,必须指定android:exported的显式值。

解决方案

你需要在自己的AndroidManifest.xml的<application>标签内部,显式声明这个Unity IAP相关的Activity,并指定android:exported属性。

修改后的完整Manifest代码如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ballsort.m14gaming" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:theme="@style/UnityThemeSelector" android:icon="@mipmap/app_icon" android:label="@string/app_name">
    <activity android:exported="true" android:label="@string/app_name" android:screenOrientation="sensorPortrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false" android:name="com.ballsort.m14gaming.UnityPlayerActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="android.notch_support" android:value="true" />
    </activity>
    <!-- 显式声明VRPurchaseActivity并设置exported属性 -->
    <activity 
        android:name="com.unity.purchasing.googleplay.VRPurchaseActivity"
        android:exported="true" />
    <meta-data android:name="unity.build-id" android:value="a152d38f-fdbc-4597-8cb0-05e3b109fb15" />
    <meta-data android:name="unity.splash-mode" android:value="0" />
    <meta-data android:name="unity.splash-enable" android:value="True" />
    <meta-data android:name="notch.config" android:value="portrait|landscape" />
  </application>
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-feature android:name="android.hardware.vulkan" android:required="false" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

补充说明

  • android:exported="true"是因为该Activity需要接收来自Google Play的购买相关跳转请求,确保IAP功能正常工作;如果你的应用不需要外部触发此Activity,也可设为false,但建议保持true。
  • 这个Activity是Unity Purchasing插件自动引入的,你的主清单未声明,导致合并时触发Android 12+的合规检查错误,显式声明即可解决。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 11:44:56