gpt4 book ai didi

安卓 4.x。通过 apk 部署 native 库并从其他应用程序加载

转载 作者:太空宇宙 更新时间:2023-11-03 10:24:50 24 4
gpt4 key购买 nike

我有几个 native 库,我想通过 apk 包部署它们(即将它们复制到 libs 文件夹或资源)。然后我需要安装单独的应用程序并使用以下方式加载这些库:

System.load(path_to_lib);

有什么方法可以做到?据我所知,出于安全原因,我不能只使用/data/data/libs_package/lib/native_lib.so 路径加载库。还有其他方法吗?

提前致谢。

最佳答案

参见 this thread在android-ndk讨论组。

总而言之,Google 的 Android 开发人员说:

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.

另一位开发者提出了以下解决方案:

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.

关于安卓 4.x。通过 apk 部署 native 库并从其他应用程序加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13951702/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com