Unity 游戏适配 Android15
Google play 要求在 2025 年8.31 号之后提审的 AAB 包必须是以 targetSdkVersion35 编译的,也就是强制必须所有应用适配 Android 15 了,支持可以延迟到 2025 年 11.1 号。
这两天正好协助游戏进行适配查了一些资料分享如下:
- 首先Unity 官方版本支持说明如下Unity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
16 KB memory page size support
16 KB 内存页面大小支持
Unity supports devices with 16 KB memory page sizes, a feature introduced in Android 15. For more information about the feature, refer to the Android documentation on Support 16 KB page sizes.
Unity 支持内存页面大小为 16 KB 的设备,这是 Android 15 中引入的功能。有关该功能的更多信息,请参阅 Android 文档中的 “支持 16 KB 页面大小” 。
Unity applications built for devices with 4 KB memory page size might not work on devices with 16 KB memory page size. To ensure your application is compatible with the devices that use 16 KB memory page size, consider the following key points:
为内存页面大小为 4 KB 的设备构建的 Unity 应用可能无法在内存页面大小为 16 KB 的设备上运行。为确保您的应用与使用 16 KB 内存页面大小的设备兼容,请考虑以下几个关键点:
Update Unity to 2021.3.48f1 or later version. Update the native plug-ins, rebuild, and resubmit your application to Google Play. The same application executable will be able to support devices with both 4 KB and 16 KB memory page sizes. For more information, refer to Android documentation on Build your app with support for 16 KB devices.
将 Unity 更新至 2021.3.48f1 或更高版本。更新原生 plug-ins ,重新构建,然后重新提交您的应用到 Google Play。同一个应用可执行文件将能够支持内存页面大小为 4 KB 和 16 KB 的设备。如需了解更多信息,请参阅 Android 文档中的 “构建支持 16 KB 设备的应用” 。
If your project contains a plug-in with a .so file that’s aligned to 4 KB instead of 16 KB, the Unity Editor displays a warning during the build process.
如果您的项目包含一个插件,其 .so 文件对齐到 4 KB 而不是 16 KB,则 Unity 编辑器会在构建过程中显示警告。
If your application uses third-party plug-ins or SDKs that link to native libraries, contact the plug-in creators to confirm that their native libraries are compatible with 16 KB page sizes. Update the relevant SDKs and resubmit your application.
如果您的应用使用了链接到原生库的第三方插件或 SDK,请联系插件开发者,确认其原生库是否兼容 16 KB 的页面大小。请更新相关的 SDK,然后重新提交您的应用。
For guidelines on testing your application on devices with 16 KB memory page sizes, refer to the Android documentation on Enable 16 KB mode on a device using developer options.
有关在具有 16 KB 内存页面大小的设备上测试应用程序的指南,请参阅 Android 文档中的使用开发者选项在设备上启用 16 KB 模式 。
所以如果你使用Unity 2021.3.48f1 或更高版本,可以将项目导出为 Android 项目,配置好相关的 NDK 环境之后,即可使用 targetSdkVersion 35 出包,同时你还可以 AGP 升级到 8.6 也可以正常出包。
- 另外目前发现一个问题,游戏针对Android碎片化的屏幕适配的不够彻底,绝大多数基本上都是全屏的游戏,竖屏的游戏基本上很少会被摄像头或刘海屏遮挡影响到,但是横屏的游戏有时候影响很严重,尤其是侧边有个功能键被前摄像头遮挡的情况。 目前能想到的解决方案是针对安全区域进行间距左移或右移。也就是将摄像头部分的元素进行横移或游戏整体 UI 元素横移,背景则覆盖全屏。
- 验证,下载最新的 Android Studio,可以创建基于 16KB Size 大内存的模拟器,安装验证即可。
1
2
3
4
adb shell getprop | grep page_size
#或
adb shell getconf PAGESIZE
#输出 16384 说明系统启用了 16 KB 页模式。
- 关于模拟器的安装以及游戏16KB SIZE验证更多你可以查看 Android官方
本文由作者按照 CC BY 4.0 进行授权