Upgrade with cocos2d-1.0.1-x-0.12.0 and integrated with your original JNI functions...

Hi,

Here are some notes that when I upgraded my game to .12 version what I learned about with new JNI architecture that cocos2d-x used.

Question 1:In the jni\helloworld\main.cpp, you can find there is already JNI_Onload() there. Yes, that means you can’t implement your JNI_Onload.

Solution:You can call RegisterNatives() at JNI_Onload() which at main.cpp instead to register your jni class.

Something like the code below :

jclass clazz;
JNIEnv *env;
vm~~>GetEnv &env, JNI_VERSION_1_6);
const char *classPathName = “com/zhihmeng/ChickenEggsX/ChickenEggsX”;
JNINativeMethod methods)) < 0) {
// LOGE (“RegisterNatives failed for ‘%s’”, className);
return JNI_FALSE;
}
Question 2:You may do some modifications on your JNI class, and JniHelper make these thing easier.
Solution:Use JniHelper to get some static method info like MessageJni.cpp does and call your method by it.
The code will like below:

JniMethodInfo t;
if V"))
{
t.env~~>CallStaticVoidMethod(t.classID, t.methodID);
}

Finally, thanks the tweaks of cocos2d-x new JniHelper, it make jni calling more elegant.

I also publish this on my blog : http://blog.molioapp.com/2012/03/upgrade-with-cocos2d-101-x-0120-and.html
And also welcome to my studio website : http://www.molioapp.com

Thank you for sharing.