Android 4.x.通过apk部署本机库并从其他应用程序加载

Android 4.x.通过apk部署本机库并从其他应用程序加载,第1张

概述我有几个本机库,我想通过apk包部署它们(即将它们复制到libs文件夹或资源). 然后我需要安装单独的应用程序并使用以下方法加载这些库: System.load(path_to_lib); 它可以通过哪种方式完成?据我所知,由于安全原因,我不能只使用/data/data/libs_package/lib/native_lib.so路径加载库.还有其他方法吗? 提前致谢. 请参阅android-nd 我有几个本机库,我想通过apk包部署它们(即将它们复制到libs文件夹或资源).
然后我需要安装单独的应用程序并使用以下方法加载这些库:

System.load(path_to_lib);

它可以通过哪种方式完成?据我所知,由于安全原因,我不能只使用/data/data/libs_package/lib/native_lib.so路径加载库.还有其他方法吗?

提前致谢.

解决方法 请参阅androID-ndk讨论组中的 this thread.

总而言之,谷歌的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.

总结

以上是内存溢出为你收集整理的Android 4.x.通过apk部署本机库并从其他应用程序加载全部内容,希望文章能够帮你解决Android 4.x.通过apk部署本机库并从其他应用程序加载所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1126813.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存