Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 伴生对象Kotlin JNI中存在未满足的链接错误_Java_Android_Kotlin_Java Native Interface - Fatal编程技术网

Java 伴生对象Kotlin JNI中存在未满足的链接错误

Java 伴生对象Kotlin JNI中存在未满足的链接错误,java,android,kotlin,java-native-interface,Java,Android,Kotlin,Java Native Interface,我正在我的一个移动应用程序中将代码从Java转换为Kotlin,而在Java中工作的代码在Kotlin中停止工作。它使用JNI桥调用C++代码。 Kotlin方法声明: class Converter{ companion object { external fun convertNative(width: Int, height: Int, row: Int, input: ByteArray, ft: Int, output: ByteArray) } }

我正在我的一个移动应用程序中将代码从Java转换为Kotlin,而在Java中工作的代码在Kotlin中停止工作。它使用JNI桥调用C++代码。 Kotlin方法声明:

class Converter{  
    companion object {
        external fun convertNative(width: Int, height: Int, row: Int, input: ByteArray, ft: Int, output: ByteArray)
    }
}
.cc代码:

   extern "C" {
    JNIEXPORT void JNICALL OBJECT_TRACKER_METHOD(convertNative)(JNIEnv* env, jobject thiz, jint width, jint height, jint row,
    jbyteArray input, jint ft, jbyteArray output);
}
    JNIEXPORT void JNICALL OBJECT_TRACKER_METHOD(convertNative)(
    JNIEnv* env, jobject thiz, jint width, jint height, jint row,
    jbyteArray input, jint ft, jbyteArray output) {...}
我得到的错误是:

java.lang.UnsatisfiedLinkError:No implementation found for void com.sampleapp.Converter$Companion.convertNative(int,int,int,byte[],int,byte[])(tried Java_com_sampleapp_Converter_00024Companion_convertNative and Java_com_sampleapp_Converter_00024Companion_convertNative__III_3BI_3B) at com.sampleapp.Converter$Companion.convertNative(Native Method)...
原始JAVA方法(这很好用)


也使用Stuly.Load库(两种情况下都看到正确的日志输出,没有错误)正确加载库。

< P>如果您想避免更改C++代码,应该用KOTLIN函数注释< C>>JVMSTATAO/<代码>,即:< /P>
@JvmStatic external fun convertNative(width: Int, height: Int, row: Int, input: ByteArray, ft: Int, output: ByteArray)

顺便说一下,您的C++函数声明在技术上是不正确的:对于静态方法,第二个参数是“代码> jCys<代码>,而不是<代码> JOBETION<代码> .p> < P>如果您想避免更改C++代码,您应该注释KTLIN函数,使用<代码> @ JVMSTATION/COD> >,即:< /P>

@JvmStatic external fun convertNative(width: Int, height: Int, row: Int, input: ByteArray, ft: Int, output: ByteArray)

顺便说一下,C++函数声明在技术上是不正确的:对于静态方法,第二个参数是“代码> jCys<代码>,而不是<代码>项目< /C>。是的,这就是缺少@JvmStatic的情况,非常感谢!