android - 如何确保应用程序与 64 位兼容?

标签 android 64-bit 32bit-64bit cpu-architecture

重要链接:

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

https://developer.android.com/distribute/best-practices/develop/64-bit#assess_your_app

如您所见:

Starting August 1, 2019: All new apps and app updates that include native code are required to provide 64-bit versions in addition to 32-bit versions when publishing to Google Play.

当您阅读该内容时,您就会明白您必须上传您的应用的两个版本,一个为 32 位编译,一个为 64 位编译。

但是你可以读到这个:

Look for native libraries using APK Analyzer APK Analyzer is a tool that allows you to evaluate various aspects of a built APK. In our case, we're going to use it to find any native libraries, and ensure 64-bit libraries are present.

  1. Open Android Studio, and open any project.
  2. From the menu, select Build > Analyze APK…
  3. launch APK analyzer
  4. Choose the APK you wish to evaluate.
  5. Look within the lib folder, which is where you will find any '.so' files. If you can not find any '.so' files in your app at all, then your app is already ready and no further action is required. If you see armeabi-v7a or x86, then you have 32-bit libraries.

要点:

在 lib 文件夹中查找,您可以在其中找到任何“.so”文件。如果您在您的应用中根本找不到任何“.so”文件,那么您的应用已经准备就绪,无需进一步操作

在我的例子中,我正在使用 Java 代码进行开发,但我无法使用 APK 分析器找到 lib 文件夹,所以......理论上,不需要进一步的操作。但是,为什么他们说“从 2019 年 8 月 1 日开始,所有包含 native 代码的新应用和应用更新在发布到 Google Play 时都必须提供 64 位版本以及 32 位版本。” ?

我有必要做某事吗?或者我可以像现在一样继续上传我的单个 APK 吗?

最佳答案

澄清一下,64 位要求仅适用于除 Java 外还使用 native 二进制文件的项目, native 二进制文件是指 c/c++ 编译的 .so 文件。 该要求指定,除了 32 位二进制文​​件之外,开发人员还必须包括 64 位变体。这可以通过两种方式完成,像往常一样使用包含两种二进制类型(32 位和 64 位 .so 文件)的单个 APK,或者将其拆分为 2 个 APK 版本。

无论哪种方式,如果您只使用 Java 开发项目,那么您无需担心,除非您依赖于自己使用 native 二进制文件的第三方库。在这种情况下,您必须确保您的任何项目依赖项还包括 64 位 native 变体。

在您的情况下,如果您在 APK 中找不到任何 *.so 文件,则无需采取进一步的操作,一切正常。

关于android - 如何确保应用程序与 64 位兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54515554/

相关文章:

c# - 64 位进程中的 AnyCPU C# DLL 加载 32 位 DLL

ios - OpenGL ES 着色器和 64 位 iPhone 5S

c# - 将字符串从 .NET 传递到 native (64 位)

delphi - 类型转换无效 : convert record to tobject on 64-bit platform

c - 编写可移植到 32 位和 64 位体系结构的代码时要考虑的要点

java - 将 View 添加到 ScrollView 会删除边距

android - 如何追查此异常的来源?

java - 格式化日期表示

findViewById 上的 android ClassCastException

c++ - Qt moc.exe - 32 位和 64 位版本之间的区别?