marcpolo
unread,Jul 9, 2012, 11:47:44 AM7/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to andro...@googlegroups.com
I'd like to call a native function from an android app to retrieve data stored in a struct or class. e.g.
class B
{
Float param1;
float param2;
}
class A
{
static
{
System.loadLibrary("MyApp");
}
static native void getData(B data);
}
In the native method I try the following
JNIEXPORT
void JNICALL Java_com_pkg_app_MyProg_getData(JNIEnv *env, jclass clazz, jobject obj)
{
jclass cls = env->FindClass("com/pkg/app/B");
jfieldID param1ID = env->GetFieldID(cls, "param1", "F");
jfieldID param2ID = env->GetFieldID(cls, "param2", "F");
env->SetFloatField(obj, param1ID, 10.0f);
env->SetFloatField(obj, param2ID, 5.0f);
}
But get the error "java.lang.NoSuchFieldError" upon the call to GetFieldID.
What am I doing wrong? I've spent most of the day searching for information on this and can only find examples on how to retrieve arrays or call methods on objects.
Any help would be appreciated. Thanks