Issue
I have a java file with the following native api signature. ( First.java)
public static native int nativePreview(int id, Surface surface);
public static native int nativetest(int id);
and in JNI File,
static JNINativeMethod methods [] = {
{ "nativetest", "(I)I", (void *)nativetest},
{ "nativePreview", "(IJLandroid/view/Surface;)I", (void *) nativePreview},
},
Respective Definitons in JNI File.
static jint nativetest(JNIEnv *env, jobject thiz, jint myid)
{
// code..
}
static jint nativePreview(JNIEnv *env, jobject thiz, jint myid, jobject surface)
{
// code
}
For the native Registration i used the below call on
env->RegisterNatives(javaConsumerClass, methods, sizeof(methods) / sizeof(methods[0]));
PROBLEM:
Interestingly, have receive the below error:
java.lang.NoSuchMethodError: no static or non-static method "Lcom/fd/sample/First;.nativePreview(IJLandroid/view/Surface;)I"
I have remove nativePreview() call, the registration is successfully done.
Question:
Have i done in right way of passing surface, or Are there anything that i have overlooked?. please help me.
Solution
Here you're saying that your function takes an int, a long, and an android.view.Surface, and returns an int:
(IJLandroid/view/Surface;)I
But that doesn't match with your definition of nativePreview:
static jint nativePreview(JNIEnv *env, jobject thiz, jint myid, jobject surface)
There's no jlong in your argument list here.
Answered By - Michael
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.