Issue
I want to copy and execute some precompiled binaries on device, the problem is that the relative folder structure needs to be the same as in the original package (I cannot move all binaries to root folder).
What so far I found about this is how to copy binaries without .so
extension to lib folder here. It works as expected, once installed I can locate the binary using context.getApplicationInfo().nativeLibraryDir
, however when I place the directory with binaries it cannot find it using the command.
Further investigation shows that folder does get coppied to apk. I can confirm that by unziping the apk and finding the binaries coppied at /lib/arm64-v8a/
.
Now since the apk is fine, the next step I did is check what actually gets copied to device. This can be found in /data/app/app.name.com+random_hash/lib/
and I confirmed that folder does not get copied over, only binaries from root folder do.
What I want to know is whether the code responsible for copying native libraries is located on device and cannot be changed, or the application can be somehow configured to copy the folder structure?
Example repo: https://github.com/D4no0/copy_native_binaries
Solution
The code is on device, part of the OS :
"Subdirectory is not supported by the Android OS.
When the APK is installed, the .so libraries are extracted to a directory in the form of /data/app/your.app/lib/. That directory is added to the library path searched by System.loadLibrary so that it can be found. System.loadLibrary do not support a directory structure, thus, the .so files in a subdirectory under lib/ are not extracted."
The above answer is coming from a Googler working on Android, from the following issue : https://issuetracker.google.com/issues/63707864#comment4
Cheers, Jérôme
Answered By - Jérôme de Bretagne
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.