本方法测试环境:UE5.4.4
参考链接:
2、【UE5】解决“上架游戏平台时,因未弹出隐私政策审核被拒”的学习笔记 - 哔哩哔哩
3、在虚幻引擎移动端项目中使用虚幻插件语言 | 虚幻引擎 5.5 文档 | Epic Developer Community
作者不熟悉安卓编程,只是尝试解决UE5这个打包问题,记录下来。
本方法优点:配置好所有内容后,可以在UE引擎里直接打包安卓包,不用其他操作。
本方法缺点:请自行体会
- 创建c++项目,我的项目名(test_Android_build),找到项目名\Source\项目名\项目名.Build.cs
在这个.cs文件里添加代码:
//导入UPL的支持
if (Target.Platform == UnrealTargetPlatform.Android)
{
PrivateDependencyModuleNames.Add("Launch");
//AndroidPlugin固定写法 不能改变
AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(ModuleDirectory, "UPL.xml"));
}
二、新建一个文件,命名为UPL.xml
把UPL.xml放在:项目名\Source\项目名\
在解决方案中:添加现有项,UPL.xml到项目名文件里
UPL.xml文件内容:
-----------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:android="http://schemas.android.com/apk/res/android">
<init>
<log text="UPL"/>
</init>
<androidManifestUpdates>
<loopElements tag="meta-data">
<setStringFromAttribute result="ApplicationSectionName" tag="$" name="android:name"/>
<setBoolIsEqual result="StartupPermissions" arg1="$S(ApplicationSectionName)" arg2="com.epicgames.unreal.GameActivity.StartupPermissions"/>
<if condition="StartupPermissions">
<true>
<removeElement tag="$"/>
</true>
</if>
</loopElements>
<addElements tag="application">
<meta-data android:name="com.epicgames.unreal.GameActivity.StartupPermissions" android:value="" />
</addElements>
<replace find="com.epicgames.unreal.SplashActivity" with="com.epicgames.unreal.PrivacyActivity"/>
<loopElements tag="activity">
<setStringFromAttribute result="ApplicationSectionName" tag="$" name="android:name"/>
<setBoolIsEqual result="SplashActivity" arg1="$S(ApplicationSectionName)" arg2="com.epicgames.unreal.SplashActivity"/>
<if condition="SplashActivity">
<true>
<removeElement tag="$"/>
</true>
</if>
</loopElements>
<addElements tag="application">
<activity android:name="com.epicgames.unreal.PrivacyActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/UnrealSplashTheme"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:screenOrientation="landscape"
android:debuggable="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- 两个对应的是用户协议和隐私政策页面内容 -->
<activity android:name="com.epicgames.unreal.PrivacyPolicy"
android:label="用户协议"
android:theme="@style/UnrealSplashTheme"
>
</activity>
<activity android:name="com.epicgames.unreal.UserAgreement"
android:label="隐私政策"
android:theme="@style/UnrealSplashTheme"
>
</activity>
</addElements>
</androidManifestUpdates>
src\com\epicgames\unreal
<!-- 复制文件 -->
<resourceCopies>
<copyFile src="$S(PluginDir)/PrivacyActivity.java" dst="$S(BuildDir)/src/com/epicgames/unreal/PrivacyActivity.java" />
</resourceCopies>
<resourceCopies>
<copyFile src="$S(PluginDir)/PrivacyPolicy.java" dst="$S(BuildDir)/src/com/epicgames/unreal/PrivacyPolicy.java" />
</resourceCopies>
<resourceCopies>
<copyFile src="$S(PluginDir)/UserAgreement.java" dst="$S(BuildDir)/src/com/epicgames/unreal/UserAgreement.java" />
</resourceCopies>
<resourceCopies>
<copyFile src="$S(PluginDir)/privacy_policy.xml" dst="$S(BuildDir)/res/layout/privacy_policy.xml" />
</resourceCopies>
<resourceCopies>
<copyFile src="$S(PluginDir)/user_agreement.xml" dst="$S(BuildDir)/res/layout/user_agreement.xml" />
</resourceCopies>
<!-- 复制文件
<resourceCopies>
<copyFile src="$S(PluginDir)/styles.xml" dst="$S(BuildDir)/gradle/app/src/main/res/values/styles.xml" />
</resourceCopies>
-->
<!-- 添加标签
<loopElements tag="resources">
<androidManifestUpdates>
<addElements tag="resources" once="true">
<intent-filter>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#000000</color>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</intent-filter>
</addElements>
</androidManifestUpdates>
</loopElements>
-->
</root>
-----------------------------------------------------------------------
---
三、准备几个文件放在:项目名\Source\项目名\
文件的链接放在后面了。
四、1修改PrivacyPolicy.java和UserAgreement.java内的import模块调用:
test_Android_build改成项目名称(上面图片)
Memory_processing改成你的公司名称(上面图片)
公司名称可以在ue5平台-打包设置里找到:
Android Package Name ('com.Company.Project', [PROJECT] is replaced with project name)
2修改打开的链接地址为你自己的地址:当前为up的地址:
3修改PrivacyActivity.java内显示的文字:
从上向下分别是你的名称、用户手册、隐私政策,名称可随意更改。
五、启动项目
上图中更改为你自己的名称。
六、打包完成。
打包中会报一些黄色的错误,只要不报红色错误,能跑通就是胜利,毕竟不熟安卓打包。
广告时间:
Up制作了一款用于碎片化时间记忆诗歌或其他知识点的游戏《天佑之人》,在taptap测试中,希望大家点个预约,捧捧场。天佑之人 - undefined官方参与测试 - TapTap
附件:
百度网盘:test_Android_build.zip
链接: https://pan.baidu.com/s/1wmomFJY7i1_Rh00IMPW1TQ?pwd=zqg7 提取码: zqg7