使用Libgdx为64位设备更新android应用 [英] Updating android app with Libgdx for 64-bit devices

查看:285
本文介绍了使用Libgdx为64位设备更新android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google Play上的Android应用程序很少.我只需要按照Google最近提到的以下要求更新应用程序即可.也就是说,所有应用都必须与64位兼容.

I have handful of apps in android on google play. I just need to update the app as per the below requirement mentioned by google recently. i.e., all the app has to be compatible with 64-bit .

https://android-developers.googleblog.com/2019/01/get-your-apps-ready-for-64-bit.html

问题:

  1. 应用程序需要进行哪些代码更改才能使其与64位设备兼容?
  2. 我们有64位版本的LibGdx吗?
  3. 如果没有可用的64位LibGdx,是否有其他解决方法?

推荐答案

我也收到了Google的电子邮件,开始怀疑我的游戏是否与64位体系结构兼容.

I've also received that email from Google and started to wonder if my game is compatible with 64-bit architectures.

回答您的问题:根据官方 libgdx更改日志在版本中添加了x64支持1.9.0(2016年1月24日发行).因此,如果您的投影是使用此版本设置的,那很好! x64已经受支持.

Answering your question: as per official libgdx changelog x64 support was added in version 1.9.0 (released 24.01.2016). So if your projected was set up using this version you're good to go! x64 is already supported.

如果(例如在我的情况下)您的项目最初使用的版本是 1.9.0之前的版本,则需要更改代码:

If (like in my case) your project initially used version prior 1.9.0 then code changes are required:

1)将以下几行添加到根build.gradle:

1) Add the following lines into root 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,所以我添加了

Note, that if you should add those two lines for each 3rd party library you're using, e.g. I have gdx-freetype-platform, so I added

    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"

2)将以下行添加到特定于android的build.gradle中:

2) Add the following lines into android-specific build.gradle:

task copyAndroidNatives() {
    ....
    file("libs/arm64-v8a/").mkdirs()
    file("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")
        .....
    }
}

3)重建项目,并检查arm64-v8ax86_64文件夹是否出现在android-> libs文件夹中,并且它们都包含libgdx.so文件

3) Rebuild project and check that arm64-v8a and x86_64 folders appeared in android->libs folder and that both of them contain libgdx.so file

4)测试!最简单的方法是在真实设备上进行测试,因为其中很多设备都支持x64.

4) Test it! Easiest way is to test on a real device since a lot of them support x64.

旁注! 如果不确定是否包含这些库,请转到Intellij Idea \ Android Studio中的构建"->分析APK",并检查lib包含arm64-v8ax86_64文件夹

Side note! If you're not sure if the libs are included go to Build-> Analyze APK in Intellij Idea\Android Studio and check that lib contains arm64-v8a or x86_64 folders

这篇关于使用Libgdx为64位设备更新android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆