Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Dear,
Please help me.....
Java
JavaVM *m_vm;
JNIEnv* env;
jobject obj;
JavaVMInitArgs vm_args;
long status = JNI_CreateJavaVM(&m_vm,(void **)&env, &vm_args);

Whenever compile of this code in android ndk.this give errorand the error is
CSS
allwikan@ubuntu:~/Desktop/NDKDemo$ ndk-build
Compile thumb  : ndk_demo <= ndk_demo.c
jni/ndk_demo.c:21:1: error: initializer element is not constant
make: *** [obj/local/armeabi/objs/ndk_demo/ndk_demo.o] Error 1

then where am i wrong.Please help me.

Thanks
Posted
Updated 18-Sep-12 1:25am
v2

1 solution

You should place the line:
C
long status = JNI_CreateJavaVM(&m_vm,(void **)&env, &vm_args);

inside a function.
E.g.


C
JavaVM *m_vm;
JNIEnv* env;
jobject obj;
JavaVMInitArgs vm_args;
long status;

void init()
{
  status = JNI_CreateJavaVM(&m_vm,(void **)&env, &vm_args);
  // other initialization stuff
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900