I trying to build android application with some precompiled native libraries: liba.so and 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.
What to do with build scripts to include all files from jniLibs into APK?
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.
Your best bet is to remove the version altogether by renaming the library and changing its internal soname
before linking against it.
Unfortunately I don't develop for Android anymore, so I can't test this, but I know Gradle and this might work for you. Looking at the Android DSL docs, you might be able to change the filtering on the jniLibs
folder:
android {
sourceSets {
main {
jniLibs.filter.include("**/*")
}
}
}
Let me know if this works!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With