How to declare native cpp method for which declared in kotlin companion object?
问题 I have a Kotlin class which just declare some methods for interaction of Kotlin and C/C++ : class JNILib { companion object { external fun getAppId(): String init { System.loadLibrary("native-code") } } } But I have a problem when declaring the native method. I tried extern "C" JNIEXPORT jstring JNICALL Java_com_package_JNILib_getAppId( JNIEnv *env, jobject /* this */){ // wrong } extern "C" JNIEXPORT jstring JNICALL Java_com_package_JNILib_Companion_getAppId( JNIEnv *env, jobject /* this */)