android / ndk-samples

Android NDK samples with Android Studio
http://developer.android.com/ndk
Apache License 2.0
9.97k stars 4.15k forks source link

Feature request: native midi Kotlin example #963

Closed sensn closed 2 months ago

sensn commented 8 months ago

It would be great to have a Kotlin version of the native_midi example app.

DanAlbert commented 2 months ago

Why? If you're looking for better examples of how to do Kotlin UIs, the NDK samples really aren't the place for that.

If I've misunderstood something lmk, but I don't think it's feasible (or even helpful) for us to have a Kotlin and Java variant of NDK samples.

sensn commented 2 months ago

Hello,

thanks for your reply. It's not so much about the UI, but how the NDK Midi library is linked and initialized from the Java/Kotlin side. When I opened the issue I was trying to migrate the Java example to Kotlin, but I ran into a lot of issues, and couldn't resolve an error about how to init the nativelib, although I used a companion object. Furthermore I read that there were some improvements to AMidi API and was wondering if they are reflected in the samples. I think docs have become more detailed in the meantime, so I might give it another try. Thanks.

DanAlbert commented 2 months ago

There's nothing unique to the midi APIs about migrating from Java to Kotlin. Use external instead of native on the managed function decl, and put your System.loadLibrary in an init block in a companion object instead of a static block.