Is it possible to configure a KMP library module s...
# multiplatform
m
Is it possible to configure a KMP library module such that
androidMain
includes .so files (
jniLibs
)? I tried a few ways but can’t seem to get the .so files bundled in the APK
s
Maybe it would allow others to help you better if you could list down the ways you have already tried. KMP, IMO, is particularly one of those frameworks that does not limit the developer. On paper, you should be able to do everything you were able to do in a native Android codebase and more.
l
It's definitely possible. I did it a couple of years ago at a previous job. I don't remember having to do anything special. Maybe check your manifest? I think there's an entry for extracting native libraries.
m
Sorry for the slow reply. I checked my manifest and I wasn’t using
extractNativeLibs
(I used to use it but removed it about a year ago, can’t remember why). Anyway, I tried setting it to
true
and
false
neither helped to include it in the APK. In my project, I have the libs in
androidMain/jniLibs/arm64-v8a
etc of the kmp library module. Any other ideas? Perhaps in the build script? I’ll continue trying things out. EDIT: .so files from external dependencies (e.g. sqlcipher, crashlytics, datastore) are being included - it’s only my ones that are not
In the end I had to move the .so files up the Android app module (which is a shame because they really belong in the library module). Even if I had got it working in the library via something like
composeResources/files
, I doubt abi splits (different APK for each abi) would have worked, so this feels like the best solution for now.