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

Carmelo M 09/15/2017. 1 answers, 84 views
java android android linux android-ndk android-ndk ndk-build

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?

5 Comments
Markus 07/27/2017
Welcome to SO! Please take some time to read the help pages, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". Also please take the tour and read about how to ask good questions. Lastly please learn how to create a Minimal, Complete, and Verifiable Example. Details about error would help a lot.
Alex Cohn 07/27/2017
That's a cool idea! But what kind of child process do you want to start? A service? I don't think this could work, because the system decides whether to turn on 32-bit mode based on analysis of your APK, and the JVM is setup accordingly.
Alex Cohn 07/27/2017
See stackoverflow.com/a/31879900/192373: the pm can force the ABI while installing the app.
Carmelo M 07/28/2017
@AlexCohn Thanks! I agree with you, a child process(Activity) can not solve this problem。 [stackoverflow.com/a/31879900/192373] is not working, because I want part of the function uses 32-bit .so, and part of the function uses 64-bit .so,in the same app.
Carmelo M 07/28/2017
@AlexCohn Do you have any other ideas? Master

1 Answers


Alex Cohn 07/30/2017.

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.

2 comments
Carmelo M 08/04/2017
That's a cool idea!!! My project is not similar to the video transcoding background operation, but need to load the three-dimensional graphics, through the SurfaceView to interact with the user gestures. How to deal with these UI interaction is a big problem, I hope you can give me some ideas, thank you
Alex Cohn 08/04/2017
I don't think you can handle UI or perform live graphics through interprocess communication

Related questions

Hot questions

Language

Popular Tags