Hey folks! A quick question: does anybody use Kotl...
# kotlin-native
s
Hey folks! A quick question: does anybody use Kotlin/Native Android NDK targets in production? If so, why?
e
This is probably a good question for r/androiddev
m
You can try, but make sure you test the hell out of API 28+ because the toolchain is 6+ years old and there are out of date sys calls being used from the kotlin native implementation that seccomp may crash your app for. Go up vote https://youtrack.jetbrains.com/issue/KT-77899
s
I'm not using it yet, but I've been considering using it for my maplibre-compose library. Specifically, I intend to someday build a KMP wrapper around the Maplibre Native core C++ library instead of around their existing iOS and Android SDKs, and then build my Compose integration on top of that. One potential architecture would look like: • maplibre-native-kotlin, a thin Kotlin wrapper of MapLibre Native Core built for all Kotlin native targets • maplibre-js-kotlin, a thin Kotlin wrapper of MapLibre GL JS built for all Kotlin browser targets • maplibre-compose, adapting the above two into a Compose library for all supported Compose targets. This architecture would involve an Android target somehow depending on an androidNative target, and I'm not sure if that's a path I can or should go down (Kotlin to Kotlin JNI?) An alternative architecture avoiding the Kotlin androidNative target would make maplibre-native-kotlin a thin Kotlin wrapper of MapLibre Native Core built for all Kotlin Apple Native targets, plus JNI adapters to build for Android and JVM targets.
m
IMHO if you are looking to also support JVM, you'll want to just go ahead and write everything in C, have a thin JNI wrapper, compile it all and load it at runtime. that's what I'm doing with
tor
via kmp-tor-resource The reason is because you'll have to cross compile for multiple platforms to support JVM, detect which to load within the JVM at runtime, extract it to
tmp
dir and load. That also means that you have to deal with codesigning for macOS & windows targets.