Android: How to call ndk function from Kotlin?

Put external fun stringFromNative(): String outside of the companion object and into the MainActivity.

(I found the answer by looking at https://github.com/ligee/kotlin-ndk-samples)

Kotlin :

call method from ndk file
 external fun stringFromJNI(): String


 load c++ file
 companion object {
        init {
            System.loadLibrary("native-lib")
        }
    }

Leave a Comment