I have a weird issue where-in 9 out of the 10 JNI functions work fine, but this new one which I just added fails. I've tried to move around this function in my list, but it still fails on this one (method II)
Any ideas? Here's how the list looks like:
static jboolean JNICALL Java_com_test_app_MyClass_JNI_AA(JNIEnv *env, jobject obj, jint iNum);
static jint JNICALL Java_com_test_app_MyClass_JNI_BB(JNIEnv *env, jobject obj);
static jobjectArray JNICALL Java_com_test_app_MyClass_JNI_CC(JNIEnv *env, jobject obj, jint iNum);
static jint JNICALL Java_com_test_app_MyClass_JNI_DD(JNIEnv *env, jobject obj, jint iNum, jint x, jint y, jint w, jint h);
static jint JNICALL Java_com_test_app_MyClass_JNI_EE(JNIEnv *env, jobject obj);
static jint JNICALL Java_com_test_app_MyClass_JNI_FF(JNIEnv *env, jobject obj, jboolean bOn);
static jint JNICALL Java_com_test_app_MyClass_JNI_GG(JNIEnv *env, jobject obj, jint iNum);
static jobjectArray JNICALL Java_com_test_app_MyClass_JNI_HH(JNIEnv *env, jobject obj);
static jint JNICALL Java_com_test_app_MyClass_JNI_II(JNIEnv *env, jobject obj);
static jint JNICALL Java_com_test_app_MyClass_JNI_JJ(JNIEnv *env, jobject obj);
static JNINativeMethod gMethods[] =
{
{"AA", "(I)Z", (void *)&Java_com_test_app_MyClass_JNI_AA},
{"BB", "()I", (void *)&Java_com_test_app_MyClass_JNI_BB},
{"CC", "(I)[Ljava/lang/String;", (void *)&Java_com_test_app_MyClass_JNI_CC},
{"DD", "(IIIII)I", (void *)&Java_com_test_app_MyClass_JNI_DD},
{"EE", "()I", (void *)&Java_com_test_app_MyClass_JNI_EE},
{"FF", "(Z)I", (void *)&Java_com_test_app_MyClass_JNI_FF},
{"GG", "(I)I", (void *)&Java_com_test_app_MyClass_JNI_GG},
{"HH", "()[Ljava/lang/String;", (void *)&Java_com_test_app_MyClass_JNI_HH},
{"II", "()I", (void *)&Java_com_test_app_MyClass_JNI_II},
{"JJ", "()I", (void *)&Java_com_test_app_MyClass_JNI_JJ},
};
The error is below when I call env->RegisterNatives(clazz, gMethods, sizeof(gMethods) / sizeof(gMethods[0]));
E/dalvikvm( 4573): ERROR: couldn't find native method
E/dalvikvm( 4573): Requested: Lcom/test/app/MyClass_JNI;.II:()I
Any ideas what I'm missing here?
Here's the code for the class:
package com.test.app;
import android.util.Log;
public class MyClass_JNI
{
private static String LIB_NAME = "jni_test";
static
{
System.loadLibrary(LIB_NAME);
}
public native boolean AA(int pos);
public native int BB();
public native String[] CC(int pos);
public native int DD(int pos, int x, int y, int w, int h);
public native int EE();
public native int FF(boolean bIsFCCOn);
public native int GG(int iNum);
public native String[] HH();
public native int II();
public native int JJ();
}
Doing a clean & rebuild as Robert H suggested does work