Android 4.x. Deploying your own libs via apk and downloading from another application

I have several native libs, and I want to deploy them through an apk package (for example, copy them to the libs folder or to resources). Then I need to install a separate application and download these libraries using:

System.load(path_to_lib); 

How can this be done? As far as I understand, I cannot just load libs using the path / data / data / libs _package / lib / native_lib.so for security reasons. Are there any other ways?

Thanks in advance.

+4
source share
1 answer

See this thread in the android-ndk discussion group.

To summarize, Google Android developers say:

If the two applications have a common user ID, you can explicitly call System.loadLibrary () with the full path to the shared library that you want to load.
...
But please do not try to do any of this. You will hurt your users β€” whether from updates to one or another application that causes incompatibility and makes you break, or a user who uninstalls another application and makes you break, etc.

And another developer offers the following solution:

So, what I'm doing now (and it works), there are a bunch of packages without a common user ID (they are signed with the same key, but I don’t think it matters here). The main application unpacks .so from .apk other packages (I already have a custom unpacker to bypass a bunch of other Android errors). I unpack them to a place known to the main package, and then dlopen () from there.

+2
source

All Articles