Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking with updated library on Android

I have developed an application and a native library for Android. The native library uses openSL ES for audio processing.

In my Android.mk file I have the following statement:

LOCAL_LDLIBS := -lOpenSLES

So I'm guessing that this means that the application will dynamically link in the openSLES library from the device's system/lib folder at the time when the application is loaded/executed on the device?

The problem I'm facing is that the libraries on the device are buggy and I have 3 updated libraries which contain the bug fix. If possible, how do I make sure that my native library is using the 3 libraries I have:

Libwilhelm.so
libOpenMAXAL.so
libOpenSLES.so

Do I just replace

LOCAL_LDLIBS := -lOpenSLES

with

LOCAL_SHARED_LIBRARIES := -lOpenSLES -lOpenMAXAL -lwilhelm
like image 447
user1884325 Avatar asked Nov 19 '15 20:11

user1884325


1 Answers

As long as you target a specific device or a very limited set of devices, the proposed solution is good enough. But if your aim is a public app, which will be installed on different platforms, including future 'N' version of Android, and customized ROMs, including e.g. Samsung, you should be careful with the system dependencies of these libraries.

While OpenSLES and OpenMAXAL are innocent (they only depend on liblog and libwilhelm), the latter requires more care.

Looking at its Android.mk, libwilhelm depends on liblog libutils libmedia libbinder libstagefright libstagefright_foundation libcutils libgui libdl libeffects and libstagefright_http_support.

Only liblog and libdl are "official" (i.e., part of NDK). The others depend on platform, and their exported functions may be incompatible for different devices running same platform level.

To be on the safe side, I would only introduce the fixes, and keep using the system version of libwilhelm when possible. I hope you can reduce your system dependencies this way.

like image 96
Alex Cohn Avatar answered Oct 31 '22 14:10

Alex Cohn