我在 google play 上有一些 android 应用程序。我只需要按照谷歌最近提到的以下要求更新应用程序。即,所有应用程序都必须与 64 位兼容。
https://android-developers.googleblog.com/2019/01/get-your-apps-ready-for-64-bit.html
问题:
- 应用中需要更改哪些代码才能使其与 64 位设备兼容?
- 我们有 64 位版本的 LibGdx 可用吗?
- 如果没有可用的 64 位 LibGdx,是否还有其他解决方法?
最佳答案
我还收到了来自 Google 的电子邮件,开始怀疑我的游戏是否与 64 位架构兼容。
回答您的问题:根据官方libgdx changelog 1.9.0 版(2016 年 1 月 24 日发布)中添加了 x64 支持。因此,如果您的投影是使用此版本设置的,那么您就可以开始了!已经支持 x64。
如果(就像我的情况一样)您的项目最初使用的是 1.9.0 之前的版本,则需要更改代码:
- 将以下行添加到根
build.gradle
中:
project(":android") {
dependencies {
....
// x32 support
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
// NEW x64 support
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
...
}
}
请注意,您应该为您正在使用的每个第 3 方库添加这两行,例如我有 gdx-freetype-platform
,所以我添加了
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
将以下行添加到特定于 android 的
build.gradle
中:任务复制AndroidNatives() { .... 文件("libs/arm64-v8a/").mkdirs() 文件("libs/x86_64/").mkdirs()
configurations.natives.files.each { jar -> .... if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a") if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64") ..... }
重建项目并检查
arm64-v8a
和x86_64
文件夹是否出现在 android->libs 文件夹中,并且它们都包含libgdx.so
文件测试一下!最简单的方法是在真实设备上进行测试,因为其中很多都支持 x64。
旁注!
如果您不确定是否包含这些库,请转到 Build-> Analyze APK in Intellij Idea\Android Studio 并检查 lib
是否包含 arm64-v8a
或 x86_64
文件夹
关于android - 使用 Libgdx 为 64 位设备更新 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54414066/