Multiple Definition of 'JNI_OnLoad' (version 0.12.0)

Multiple Definition of 'JNI_OnLoad' (version 0.12.0)
0.0 0


Hi all,

I’m new to JNI. It seems that there is multiple definition of JNI_OnLoad, the first one in jni/helloworld/main.cpp, and the other one is in the jni/customJNI.cpp that I created. I basically created customJNI based on CocosDenshion/Android/jni/SimpleAudioEngineJni.cpp. When I compiled using cygwin, it returns the error that there is multiple definition of ‘JNI_OnLoad’.

Please help me to solve this problem because I have to use JNI. Thanks.


if you are using jni_onload to get only the JavaVM, you can try to use the JniHelper

#include <JniHelper.h> . . . JavaVM * gJavaVM = cocos2d::JniHelper::getJavaVM();

to this works you have to add this in your at LOCAL_C_INCLUDES


Thanks, it solves the problem.