So, my code right now is like it loads library (say liba.so) from Java-layer and internally liba.so loads libb.so. So, if I have to pack all the libraries inside an APK and install it on a device with no root access then what is the procedure to structure my project in which one load call from Java-layer will load both the libraries, first liba.so (direct call) and then libb.so (second call, nested call, call from liba.so)?
Asked
Active
Viewed 713 times
0
-
Could you please add your code? – creyD Feb 02 '18 at 09:13
-
In my Java file, I am loading from System.loadLibrary(liba.so) And then in liba.so's source file I am using dlopen to open libb.so. I want to know how will I be able to pack them in an APK such that liba.so call libb.so internally. Right now, I am able to call liba.so from Java-layer but libb.so is not getting called from liba.so – Shantanu Srivastava Feb 02 '18 at 09:19
1 Answers
1
If both liba.so and libb.so are packed into your APK, then the installer will unpack both to the nativeLibraryDir.
From Java, loadLibrary() will look in this directory automatically. But dlopen() is not aware of this path. You must provide to dlopen() the full path to the installed libb.so.
Alternatively, you can load libb from Java, then it will be in memory and liba will find it's exported symbols without dlopen().
If you need to understand better the process of packing the libraries into APK, consult this wonderful answer.

Alex Cohn
- 56,089
- 9
- 113
- 307