Jni: Can Not Get Array Length
Solution 1:
The second argument passed to your function isn't a jbyteArray
.
Per the JNI documentation, the arguments passed to a native function are:
Native Method Arguments
The JNI interface pointer is the first argument to native methods. The JNI interface pointer is of type JNIEnv. The second argument differs depending on whether the native method is static or nonstatic. The second argument to a nonstatic native method is a reference to the object. The second argument to a static native method is a reference to its Java class.
The remaining arguments correspond to regular Java method arguments. The native method call passes its result back to the calling routine via the return value.
Your jstring convertToHex(JNIEnv* env, jbyteArray array)
is missing the second jclass
or jobject
argument, so you're treating either a jobject
or jclass
argument and a jbyteArray
.
Solution 2:
Your native method signature is incorrect. It should be
static jstring convertToHe(JNIEnv *env, jobject thiz, jbytearray array)
Post a Comment for "Jni: Can Not Get Array Length"