Android N compatibility-HELP

134 views
Skip to first unread message

Viru chauhan

unread,
Jun 19, 2018, 11:23:42 AM6/19/18
to android-ndk
For Help
Dear All Android Developer,
I have develop one android application call recording.This app work fine up to 6.0. i record call using mic and some audio settings changes using native lib like dlopen("libmedia.so") and use libmedia function and modified audio but in android 7.1 & 7.2 android os some changes is i am not use dlopen("libmedia.so") it retruns "NULL".i know why this retrun NULL it's about private lib i can not access using android-ndk any private lib than my Question is how to access private lib in android 7.1 &7.2 please help for step by step solution.. 
i need solution with development steps. 

Andrew Esh

unread,
Jun 19, 2018, 1:07:40 PM6/19/18
to android-ndk
I ran into this problem trying to load Gstreamer plugins that I had packaged as private libraries with my application. In Android N, they began adding an extra path element to where the private libraries are installed. Each time the app is installed, a new random name is used to create a directory for the libraries. (This is done to prevent other apps from using private libraries from another application.) I had to make a Native-to-Java call to get the path from the app context like this:

return MyCustomApp.getContext().getApplicationInfo().nativeLibraryDir;

Prepend this string to the file name in the dlopen call, and the library will be found.

Alex Cohn

unread,
Jun 25, 2018, 7:41:53 AM6/25/18
to android-ndk
If you need /system/lib/libmedia.so you should reconsider your design.

BR,
Alex

Alex Cohn

unread,
Jun 25, 2018, 7:47:52 AM6/25/18
to android-ndk
On Tuesday, June 19, 2018 at 8:07:40 PM UTC+3, Andrew Esh wrote:
I ran into this problem trying to load Gstreamer plugins that I had packaged as private libraries with my application. In Android N, they began adding an extra path element to where the private libraries are installed. Each time the app is installed, a new random name is used to create a directory for the libraries. (This is done to prevent other apps from using private libraries from another application.) I had to make a Native-to-Java call to get the path from the app context like this:

return MyCustomApp.getContext().getApplicationInfo().nativeLibraryDir;

There is an easier way to find that out, when you are already in a native library: check the directory for the loaded module, see https://stackoverflow.com/a/1681259/192373. TL;NR: use dladdr()
 
BR,
Alex
Reply all
Reply to author
Forward
0 new messages