Search code examples
javaandroidlinuxandroid-ndkndk-build

How to mix 32 and 64-bit .so files in an app


First,I know that in an app does not allow mixed use of different architectures of the .so file(Part only uses 32, the other part only uses 64)

So,I tried to Open a new process to dynamically load 64 and 32-bit so files,but System.load()throw the error and app crashed! How to solve this problem through multiple processes? Or is there any other way to solve this?


Solution

  • Well, I did try. On the face of it, this works: use armeabi shared libs 'in the usual way', and run a arm64-v8a executable from Java with Runtime.exec() or from C with system().

    You can put the executable in assets and unpack it manually, or you can cheat and rename it so that it starts with lib and ends with .so; now you can put this file in the jniLibs/armeabi directory.

    The opposite way works, too: launch 32-bit executable (don't forget -fPIE) from 64-bit app.

    Make sure that the library search paths do not clash.