Sub-directories in the lib/armeabi and armeabi-v7a folder

437 views
Skip to first unread message

Vitakot

unread,
May 31, 2012, 3:46:26 PM5/31/12
to android-ndk
I have one universal shared native library which is linked against
other shared library existing for various ARM versions and extensions.
I have to switch which one to use at runtime. My Android.mk is simple:

include $(CLEAR_VARS)
LOCAL_MODULE := player

LOCAL_SRC_FILES := some_cpp_sources...

LOCAL_LDFLAGS := -L$(LOCAL_PATH)/../bin
LOCAL_LDLIBS := -llog -lz -lm –lplayer_engine
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

include $(BUILD_SHARED_LIBRARY)

The problem is:

- I have to specify the native library (player_engine) - which the
main library depends on, at the link time
- I have more versions of the player_engine library
- Libraries must have same names; otherwise I would need to specify
all of them in the Android.mk script which would lead to
UnsatisfiedLinkError exceptions when trying to load only the correct
one according to the ARM version and extension

Build script creates only armeabi and armeabi-v7a subfolders in the
libs folder, any other manually created subfolder is deleted once the
apk is created.

How to solve this problem?

David Turner

unread,
May 31, 2012, 7:13:09 PM5/31/12
to andro...@googlegroups.com
- Put your "engine" libraries as raw resources in your .apk. Only the "player" libs should go into libs/$ABI/ and will be installed by the PackageManager when your app is installed.

- On first run, manually extract the right "engine" library to a fixed location (e.g. into Context.getFilesDir() + "/libplayer_engine.so"

- On startup, after the step above, manually load the engine library by calling System.loadLibrary() with the full path to your extract lib

- After this, load your "player" library with System.loadLibrary("player");


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Reply all
Reply to author
Forward
0 new messages