如何使用Gradle将版本* .so文件包含到APK中? [英] How to include versioned *.so file into apk using Gradle?

查看:105
本文介绍了如何使用Gradle将版本* .so文件包含到APK中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用一些预编译的本机库构建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 $ 被用于非常受限制,并且很有可能无法加载它们.

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中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆