Building APK removes native library version number from filename

0

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.

android
apk
native
version-numbering
android-native-library
asked on Stack Overflow Feb 13, 2012 by Marcin Gil • edited Aug 28, 2019 by JoshDM

1 Answer

0

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.

answered on Stack Overflow Mar 8, 2012 by spemin

User contributions licensed under CC BY-SA 3.0