Android JNI:与 64 位设备的 32 位兼容性? [英] Android JNI: 32-bit compatability with 64-bit devices?

查看:49
本文介绍了Android JNI:与 64 位设备的 32 位兼容性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些使用原生组件的库,这些库是用 NDK 构建的,适用于 32 位 Arm 架构.

I have some libraries that use native components, the libraries are built with NDK for 32 bit Arm architectures.

现在我们在现代设备上有 64 位处理器,所以我想知道这些库是否可以工作.在我的情况下,我没有本机库的源代码文件,只有 SO 文件,我无法为 64 位构建它们.

now we have 64-bit processors on modern devices, so I'm wondering if the libraries will work. In my situation, I don't have the source code files of the native library, just the SO files, I can't build them for 64-bits.

那么 32 位库会在 64 位处理器上运行吗?还是我必须重新构建它们?

So will the 32-bits libraries run on 64-bits processors? or I have to re-build them?

**

编辑

**在我的场景中,我有以下内容:

** In my scenario I have the following:

1- 我手动分发 APK,尚未发布到 Google Play.

1- I distribute the APK manually, didn't publish to Google Play yet.

2- 该项目有两个本机库,一个是 64 &支持 32 位,另一种仅支持 32 位.

2- The project has two native libraries, one with 64 & 32-bits support and the other with 32-bits only.

现在有没有办法让应用程序在 64 位设备上运行而无需发布到 Google Play?我可以删除 64 位库以强制包管理器加载 32 位库吗?

Is there a way to make the application work on 64-bits devices without having to publish to Google Play for now? can I remove the 64-bits libs to enforce the package manger to load the 32-bits ones?

推荐答案

32 位库在 64 位处理器上也能正常工作.

The 32 bits libraries will work just fine on 64 bits processors.

只要库以正确/官方的方式安装(即,不是手动下载或从 APK 中的某些非标准部分提取,而是在 APK 中正确打包),包管理器将检测到该进程使用 32 位库,并且该进程应以 32 位模式启动.如果没有,进程将以 64 位模式启动,以后将无法加载 32 位库.(如果您的 APK 将包含一些 .so 文件,但不是全部,在 64 位模式下,它只会安装它们,并且该进程将在 64 位模式下启动.因此,除非所有 .so 文件都可用于特定的 ABI,不包括其中任何一个).

As long as the libraries get installed the right/official way (i.e., not manually downloaded or extracted from some nonstandard part in the APK, but packaged properly in the APK), the package manager will detect that the process uses 32 bit libraries, and the process should be started in 32 bit mode. If not, the process will be started in 64 bit mode, and later will be unable to load 32 bit libraries. (If your APK would contain some .so files, but not all, in 64 bit mode, it would only install them, and the process would be launched in 64 bit mode. So unless all .so files are available for a specific ABI, don't include any of them).

因此,如果您拥有其中一个本机库的 64 位版本,只需将其删除并仅提供 32 位版本,直到您拥有所有这些库的 64 位版本.

So if you have a 64 bit version of one of the native libraries, just remove that and only ship the 32 bit version, until you have 64 bit versions of all of them.

这篇关于Android JNI:与 64 位设备的 32 位兼容性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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