hi, I write enum in my commonMain at K/N project, ...
# kotlin-native
v
hi, I write enum in my commonMain at K/N project, then build .so for Android. Now how can I use this enum ?? thanks~
m
If you want to use that enum from java/kotlin (JVM) Android, you can't really do that. JVM to native calls go though JNI and anything other than primitive types (not including Strings) must be manually (un)wrapped in native code.
o
why would you need K/N in such a case anyway?
v
Thanks, I see. I only don’t want to write twice on Android/iOS
o
then you shall use Kotlin/JVM on Android and Kotlin/Native on iOS
m
see some kotlin multiplatform example
ideally, you'll use JVM on Android and K/Native on iOS (there's no need for K/N and .so libs on Android)
g
Hello. But please @olonho, what if you then have a custom C library that you want to use on Android?
m
You can either call compiled C code over JNI from JVM or call C code from K/N which itself is called over JNI from JVM. JNI is a must if you're calling from JVM, I'm not sure sure if there is some tooling made to ease JNI boilerplate
g
Thanks, @Marko Mitic. I hope there will be a tool to replace JNI in the future.
m
Someone probably made some tool that helps with generating JNI bindings as it's not that hard to do, but I haven't worked with JNI for some time and I'm not following the developments in that area
g
OK. Thanks again, @Marko Mitic.🙏