简体   繁体   English

通过安装APK将.so推送到Android平台的/ system / lib中

[英]Pushing .so in /system/lib of Android platform by installing an APK

Our APK has a shared library (libxyz.so). 我们的APK有一个共享库(libxyz.so)。 When that APK is installed, it pushes the .so file in /data/app-lib/packagename/. 安装该APK后,它将.so文件推送到/ 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. 我们希望不要在此路径上走,而是应在安装APK时将.so自动推送到/ system / lib。 However, the /system/lib requires permissions and privileges. 但是,/ system / lib需要权限和特权。

The reason why we want to push the .so to /system/lib is that it could be loaded by other applications as well. 我们之所以要将.so推送到/ system / lib是因为它也可以由其他应用程序加载。 (Could there be any other way for two apps to share the same libxyz.so) (两个应用是否可以通过其他任何方式共享同一个libxyz.so)

What could be the possible ways to achieve the purpose ? 达到目的的可能方法是什么?

We want that instead of going at this path, the .so should be pushed to /system/lib automatically at the time of APK install 我们希望不要沿着这个路径走,而是应该在安装APK时将.so自动推送到/ system / lib

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 我们之所以要将.so推送到/ system / lib的原因是,它也可以由其他应用程序加载

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. 这就是Google竭尽全力减少API更改的原因,即使是以某些东西不在开发人员希望拥有的公共API中为代价。 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. 欢迎您创建包含此.so的Android自定义版本,创建包含该自定义版本的ROM mod,并将该ROM mod部署到您控制的设备上。

If you have a rooted device, you can use cp to copy .so to /system/lib 如果您拥有根设备,则可以使用cp.so复制到/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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM