Building APK removes native library version number from filename
-
29-04-2021 - |
質問
I have a legacy code that uses autotools to build shared libraries. These libraries need to be used in an Android application so I've created a simple Java class and JNI wrapper for it (as a shared .so library).
I already have Android.mk script that properly executes legacy build system, builds native library for Java program and links it.
The output files are as follow:
libs/armeabi/lib-a.so.0
libs/armeabi/lib-b.so.2
libs/armeabi/lib-wrapper.so
lib-wrapper.so
depends on both libraries lib-a
and lib-b
. Notice that the legacy autotools setup adds version number to shared library file name - which is embedded as dependency in lib-wrapper.so
.
# arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-readelf -d ./lib-wrapper.so
Dynamic section at offset 0x7608 contains 28 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [lib-b.so.2]
0x00000001 (NEEDED) Shared library: [lib-a.so.0]
The problem:
during APK building the (eg. export unsigned package from Eclipse) the version numbers
are stripped from file names. This results in error:
Cannot load library: link_image[1721]: 30 could not load needed library 'lib-b.so.2' for 'lib-wrapper.so'
because APK contains file lib-b.so
.
How can I force retaining version numbers during APK building?
Modifying legacy build system is rather not possible (until it's a must) as the same setup is used to build x86 libraries/execs.
Thank you.
正しい解決策はありません
他のヒント
The android linker does not recognise the shared libraries not ending with ".so". You need to change the filename created by the legacy build system.