问题描述
我尝试使用一些预编译的本机库构建android应用程序: liba.so 和 libb.so.1.2.3
I trying to build android application with some precompiled native libraries:liba.so and libb.so.1.2.3
库放置在jniLibs子目录中.构建APK文件后,仅包含 liba.so ,但没有包含 libb.so.1.2.3 .
Libraries are placed into jniLibs subdirectory.After building APK file, only liba.so included into it, but not libb.so.1.2.3.
结果是可预测的.应用程序在启动时崩溃.
Result is predictable. Application crashes at start.
如何使用构建脚本将jniLibs中的所有文件都包含到APK中?
What to do with build scripts to include all files from jniLibs into APK?
推荐答案
由于本机库正则表达式 ^.+ \\.so $
被用于 Android Gradle插件,使用 jniLibs
文件夹无法包含除 .so
文件之外的任何文件.而且,即使您要以某种方式将库添加到APK,Android上的动态加载程序也非常受限制,并且很有可能无法加载它们.
Due to the native library regex ^.+\\.so$
being used in the Android Gradle plugin, it is impossible to include anything other than .so
files using the jniLibs
folder. And even if you were to somehow add the library to the APK, the dynamic loader on Android is very limited and will most likely not be able to load them.
您最好的选择是通过重命名该库并更改其内部 soname
之前的版本来完全删除该版本.
Your best bet is to remove the version altogether by renaming the library and changing its internal soname
before linking against it.
这篇关于如何使用Gradle将版本* .so文件包含到APK中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!