Search code examples
androidandroid-ndkjava-native-interface32bit-64bit

Android JNI: 32-bit compatability with 64-bit devices?


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

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.

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

**

EDIT

** In my scenario I have the following:

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

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

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?


Solution

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

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

    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.