Reputation: 11
Our APK has a shared library (libxyz.so). When that APK is installed, it pushes the .so file in /data/app-lib/packagename/.
We want that instead of going at this path, the .so should be pushed to /system/lib automatically at the time of APK install. However, the /system/lib requires permissions and privileges.
The reason why we want to push the .so to /system/lib is that it could be loaded by other applications as well. (Could there be any other way for two apps to share the same libxyz.so)
What could be the possible ways to achieve the purpose ?
Upvotes: 1
Views: 1700
Reputation: 2320
If you have a rooted device, you can use cp
to copy .so
to /system/lib
Process process = Runtime.getRuntime().exec("su");
DataOutputStream writer = new DataOutputStream(process.getOutputStream());
writer.writeBytes("cp /your/path/xxx.so /system/lib/xxx.so");
writer.flush();
Upvotes: 0
Reputation: 1007266
We want that instead of going at this path, the .so should be pushed to /system/lib automatically at the time of APK install
That is not possible.
The reason why we want to push the .so to /system/lib is that it could be loaded by other applications as well
That would be a bad idea, even if this were possible. You have no means of forcing the user to upgrade all applications that would use this library. Unless you are very very careful, apps will crash because they are expecting an older version of the library and you updated the common copy to a new one. This is why Google goes to very great lengths to minimize API changes, even at the cost of having some things not be in the public API that developers would like to have. This is generally referred to as "dependency hell".
What could be the possible ways to achieve the purpose ?
You are welcome to create a custom build of Android that contains this .so
, create a ROM mod that contains that custom build, and deploy that ROM mod to devices that you control.
Upvotes: 1