Wish Support for abiFilters or packagingOptions when compiling

moster67

Expert
Licensed User
Longtime User
This might be related to my post here below although I am not entirely sure it relates:
https://www.b4x.com/android/forum/t...es-include-all-libs-in-apk.88059/#post-557273

I have a user that uses my new Vitamio5.23-wrapper which has support for 64bit architecture. Due to decoding issues, he needs to use my VLC-wrapper too but when both libs are included in the same project, VLC will fail with:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/b4a.example-2/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-2/lib/arm64, /data/app/b4a.example-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libcompat.7.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:972)
....

This happens only on 64bit-devices such as Samsung S7, S8 but on my old 32bit-device Samsung S3 everything works fine. Also, when the two libraries are not mixed together in the same project, the wrappers work fine on 64bit-devices since Vitamio will use the 64bit-lib while with VLC (with no 64bit-support) Android falls back to use the 32bit-library.

It looks like I managed to resolve this (at least on my S8) by compiling a 32bit version of my Vitamio-wrapper (removing the library-folder "arm64-v8a" and its content). Now, when the app with Vitamio and VLC runs on a 64bit-device, everything works fine. Also the project mentioned in the first paragraph now works fine on 64bit-devices.

So apparently when there is native library that supply 64-bit .so files, the system assumes 64-bit .so files are provided in all cases.

Here are some links which seem to talk about the same issue:
https://stackoverflow.com/questions...es-on-64-bit-android-device/30799825#30799825
https://stackoverflow.com/questions/32441359/gradle-exclude-arm64-libs?noredirect=1&lq=1

I don't know if Google with Android Studio has now included a solution for this problem but the suggested solution seems to be to exclude the 64bit native libraries when compiling.

It seems like it can be done when compiling in Android Studio by setting abiFilters to package only 32-bit architectures:
B4X:
android {
    ....
    defaultConfig {
        ....
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
        }
    }
}

and adding
B4X:
android.useDeprecatedNdk=true
to a file named gradle.properties at the root of your project.

An alternative way seems to be by excluding the specific *.so files for the architectures we do not want to support using packagingOptions:
B4X:
packagingOptions {
  exclude 'lib/arm64-v8a/lib.so'
  exclude 'lib/mips/lib.so'
}

So my wish is that we can have the same possibility to filter out the 64bit so-files or excluding them when compiling our B4A-project.
This would avoid the necessity for us developers to create two versions of our wrappers (Full architecture support and only 32bit support).

Thanks.
 
Last edited:
Top