Question

I have several native libs and I want to deploy them via apk package (i.e. copy them to libs folder or to resources). Then I need to install separate application and load those libs using:

System.load(path_to_lib);

Which way it can be done? As I understand I can't just load libs using /data/data/libs_package/lib/native_lib.so path because of security reasons. Are there any other ways?

Thanks in advance.

No correct solution

OTHER TIPS

See this thread in the android-ndk discussion group.

To summarize, Google's Android devs say:

If the two applications have a shared user ID, then you can explicitely call System.loadLibrary() with the full path to the shared library you want to load.
...
But please do not try to do any of this. You are going to cause pain for your users -- whether from updates of one or the other app causing incompatibilities and making you break, or the user uninstalling the other app and making you break, etc.

And another developer proposes the following solution:

So what I do now (and it works) is have a bunch of packages without a shared user id (they are signed by the same key, but I don't think that is important here). The core app unzips the .so from the .apk of the other packages (I already have a custom unpacker to workaround a bunch of other Android bugs). I unpack them to a location known by the core package and then dlopen() them from there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top