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

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

问题描述

我在 google play 上有一些安卓应用.我只需要根据谷歌最近提到的以下要求更新应用程序.即,所有应用程序都必须与 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

Questions:

  1. what code changes is needed in the app to make it compatible with 64-bit devices ?
  2. Do we have 64-bit version of LibGdx available ?
  3. If there is no 64-bit LibGdx available is there is any other work around to resolve this ?

解决方案

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

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.

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

  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"
         ...

       }
    }

Note, that 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"

  1. 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")
         .....
     }
    

    }

  2. 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

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

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天全站免登陆