Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load native shared library from another Android application

I need to distribute an application (a player), which depends on a native library built for a given ARM version and extension (Tegra, Neon). This native library is quite large so I can’t distribute all its versions in one universal package. So I decided to split the application into one small universal .apk and more specialized .apks – plug-ins without any activities.

How can I access a specialized native shared library in the plug-in app from the main host application? Is it possible to use simply

System.loadLibrary("path_to_library"); 

If so, how can I get the path to that library?

How to solve this problem in case it is not possible?

like image 321
vitakot Avatar asked Jun 04 '12 12:06

vitakot


1 Answers

System.loadLibrary() takes a library name and maps it to a full path somehow.

foo => libfoo.so

The system normally checks the apk itself and then usually /system/lib/

If you have a full path, use System.load()

In any case it will be a hassle to manage the location of your lib unless it's either in the apk or with all the system libs.

I'd just pack the specific lib with the apk.

like image 184
Renate Avatar answered Nov 15 '22 14:11

Renate