We are trying to use some '.so' prebuilt libraries for our android project. These are:
mpeg.so
& lib_arch.so
When gradle's debuggable
flag is true, our '.so' files are visible in '.apk' file(confirmed using ApkAnalyzer) and they are, also, available in /data/app/<package-name>-jekswbj/lib
folder when app is installed.
When debuggable
flag is set to false, our '.so' files are visible in '.apk' file(confirmed using ApkAnalyzer). But, mpeg.so
is not stored on device when app is installed. Only lib_arch.so
is found.
Following are snippets from my build.gradle
file
// buildTypes: debug {}
debug {
debuggable false
minifyEnabled false
ext.enableCrashlytics = false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
// splits: abi
splits {
abi {
enable true
reset()
include 'x86', 'x86_64', 'arm64-v8a', 'armeabi-v7a'
universalApk true
}
}
Our '.so' files are stored in <module-name>/libs/<abi-name>
folder according to their abi(s). But, they appear in jniLibs
folder as in following image in Android Studio.
So, the mpeg.so
file is found when debuggable
is true, but it is missing when debuggable
is false. What is causing this issue? I can provide more information if you need it.
For me, the solution was to prefix all .so
libraries with keyword lib
. Yes, right.
My library names were as following:
Before Change:
mpeg.so
lib_arch.so
After Change:
libmpeg.so
libarch.so
And, now, I was able to find them both in the apk and installation directory.
Most relevant documentation reference I have found is:
Note: If your module's name already starts with lib, the build system does not prepend an additional lib prefix; it takes the module name as-is, and adds the .so extension. So a source file originally called, for example, libfoo.c still produces a shared-object file called libfoo.so. This behavior is to support libraries that the Android platform sources generate from Android.mk files; the names of all such libraries start with lib.
And, I am not even using ndk or android.mk