I have an application which uses native libraries for various targets – ARMv6, ARMv6+vfp, ARM7+vfp, ARM7+Neon, ARM7 + Tegra as well as some universal libraries. My goal is to pack all the libraries into one .apk file so that I don’t have to distribute separate builds – I don’t care a much about the total .apk size.
Here is my Android.mk script – just an example but with enough info:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
TARGET_ARCH_ABI := armeabi
LOCAL_MODULE := prebuilt_arm_v6vfp
LOCAL_SRC_FILES := ../bin/libplayer_v6vfp.so
LOCAL_EXPORT_LDLIBS := ../libplayer_v6vfp.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
TARGET_ARCH_ABI := armeabi-v7a
LOCAL_MODULE := prebuilt_arm_v7n
LOCAL_SRC_FILES := ../bin/libplayer_v7n.so
LOCAL_EXPORT_LDLIBS := ../libplayer_v7n.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := player
LOCAL_SRC_FILES := some_cpp_sources...
LOCAL_LDFLAGS := -L$(LOCAL_PATH)/../bin
LOCAL_LDLIBS := -llog -lz -lm -lplayer_v7n -lplayer_v6vfp
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
include $(BUILD_SHARED_LIBRARY)
Now I have the following problem – it creates libs folder with armeabi and armeabi-v7a subfolders – that’s OK. But the content of both subfolders is the same, both contains libplayer_v7n.so and libplayer_v6vfp.so as well.
How can I assure each subfolder contains only a correct version of native library according to its eabi version?
EDIT 1:
As you can see, I link libplayer.so with both shared libraries, they have compatible interfaces. I wanted to select the correct library dynamically when loading in my Java wrapper after detecting the CPU type. But it seems it is not possible. Any idea how to choose the correct library dynamically? There must be a solution for such a common case.
EDIT 2:
It seems I can link my libplayer.so only with one library and have to select its correct version at runtime. But now the problem is how to store six native libraries of various versions but with the same name in the lib folder. Subfolders seem to be an obvious solution, but I am not sure it is possible. The other solution would be to deploy the correct library via the separate .apk as a plug-in, but that’s exactly I want to avoid..
Then do the following:
.