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

Unity上传AAB至Google Play报android:exported属性缺失错误解决

问题描述

上传aab安装包到Google Play时收到如下官方报错:

You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without the 'android:exported' property set. This file can't be installed on Android 12 or higher.

已手动修改两个路径下的AndroidManifest.xml清单文件,重新打包后仍出现相同报错,涉及的文件路径为:

  • C:\android\App\Assets\Plugins\Android\AndroidManifest.xml
  • C:\android\App\Assets\Plugins\Android\OneSignalConfig.plugin\AndroidManifest.xml

经排查,问题根源为OneSignal存在未展示在上述OneSignalConfig.plugin目录清单文件中的隐式配置项,Unity构建时会自动完成所有依赖清单的合并流程,无法直接修改最终生成的合并版AndroidManifest.xml文件。

解决方案

按优先级从高到低选择以下方案处理即可:

  • 优先升级OneSignal Unity SDK到3.0.4及以上的稳定版本。该版本及后续版本已完成Android 12适配,所有带intent-filter的组件均已预设android:exported属性,构建时会自动合并正确配置,无需额外手动修改。
  • 若暂时无法升级SDK,可借助Unity的Manifest合并规则,在项目主清单文件中强制覆写缺失的属性,操作步骤如下:
    1. 打开项目主AndroidManifest文件(即Assets/Plugins/Android目录下的根清单),在<manifest>根节点添加tools命名空间:
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="替换为你的应用实际包名">
    
    1. 在<application>节点内添加OneSignal所有缺失exported属性的组件配置,通过tools:replace属性强制覆盖依赖中的默认配置:
    <!-- 补全OneSignal组件的exported属性 -->
    <service
        android:name="com.onesignal.GcmIntentService"
        android:exported="false"
        tools:replace="android:exported"/>
    <service
        android:name="com.onesignal.GcmIntentJobService"
        android:exported="false"
        tools:replace="android:exported"/>
    <receiver
        android:name="com.onesignal.GcmBroadcastReceiver"
        android:exported="true"
        tools:replace="android:exported">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </receiver>
    <service
        android:name="com.onesignal.RestoreJobService"
        android:exported="false"
        tools:replace="android:exported"/>
    <service
        android:name="com.onesignal.RestoreService"
        android:exported="false"
        tools:replace="android:exported"/>
    <activity
        android:name="com.onesignal.NotificationOpenedActivity"
        android:exported="false"
        tools:replace="android:exported">
        <intent-filter>
            <action android:name="com.onesignal.NOTIFICATION_OPENED" />
        </intent-filter>
    </activity>
    
  • 打包完成后先做本地校验,不要直接上传:打开项目下的Temp\StagingArea\AndroidManifest.xml文件(即Unity构建时合并生成的最终清单),全局检索所有带<intent-filter>标签的组件,确认每一个activity、service、receiver、activity-alias都明确配置了android:exported属性,无遗漏后再上传Google Play。

注:如果项目中其他第三方SDK也存在同类缺失exported属性的问题,均可参照上述覆写规则在主Manifest中补全配置,无需修改SDK内部的清单文件。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.30 17:24:21