How would I set up Gradle to build the android nat...
# kotlin-native
m
How would I set up Gradle to build the android native targets (arm64, armv7, x86) using kotlin-native rather than cmake?
l
You can add the androidNative* targets to your build.gradle.kts and create corresponding source sets (I’d create an androidNdkMain source set and add the others as dependsOn). This will allow you to build the binaries for android ndk. From there, there’s not a good gradle way to automatically build and move them, so I usually copy a gradle task I wrote a while back.
Here's an example project where I set this up. I currently have it set to where you have to manually run the task to update the binaries. I just have to run
./gradlew prepareAndroidNdkSo
The native targets take a while to build sometimes and it’s hard to only build the one you need when you click run, so I’d recommend making it a manual process to trigger the prepareAndroidNdkSo task instead of running it every time.
m
Is there a way to commonize between desktop JNI, android JNI and WASM-interop?
l
Funny you should ask. I just sat down to start adding that to JniUtils.
As far as I can tell, there's not a good way to do that by default, since the def file is set up for us by the Kotlin toolchain, so I don't think we can configure the packages to match.