APK: native libraries name issues related to version number (SO.X.Y)

Viewed 146

Issue

Built APK looks wrong and prevents my application from loading its native library because it cannot find a dependency when calling dlopen(): dlopen failed: library "libboost_filesystem.so.1.68.0" not found.

jniLibs content

My jniLibs directory, for the target platform, contains the following files:

  • libboost_filesystem.so.1.68.0 is the "real" shared object.
  • libboost_filesystem.so is a symlink to libboost_filesystem.so.1.68.0

APK Content

After building, the APK contains a libboost_filesystem.so which now is the binary object (not a symlink). It seems like Android build system followed the symlink, grabbed content of the "pointed-to" file, but used the name of the symlink instead.

I have tried to remove the symlink from the jniLibs folder, but doing that it seems that the xxx.so.VERSION files are then ignored.

Question

How can I embed my "full name" shared object into the jniLibs without the Android build system messing with it ?

1 Answers

No you can't. You should avoid versioning the so file. See https://stackoverflow.com/a/45058227/192373 for instructions.

It's also quite natural that Android does not support this technique, because your native libraries belong to your APK and no version conflict can occur.

Consider linking boost filesystem statically to avoid extra lookup.

Related