Hi, I’m using cocos2d-x-2.2.6 and my app crashes, when runnin on a device.
logcat points me on Cocos2dxRenderer.java file and it crashes in
@Override
public void onSurfaceCreated(final GL10 pGL10, final EGLConfig pEGLConfig) {
Cocos2dxRenderer.nativeInit(this.mScreenWidth, this.mScreenHeight);
this.mLastTickInNanoSeconds = System.nanoTime();
}
on calling Cocos2dxRenderer.nativeInit(this.mScreenWidth, this.mScreenHeight);
error is:
JNI DETECTED ERROR IN APPLICATION: JNI FindClass called with pending exception ‘java.lang.NoSuchMethodError’ thrown in void org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(int, int):-2 in call to FindClass
@shauket the codes in main.cpp seems good, did you modify Cocos2dxRenderer.java? Is private static native void nativeInit(final int pWidth, final int pHeight); in Cocos2dxRenderer.java?
I have not idea. The error means it can not found the nativeInit(), but it is implemented in main.cpp. The only possibility is that, main.cpp is not compiled? But i think it is not possible.
Could you please run the following command to check if nativeInit is included in libhellocpp.so like this
/Users/minggo/bin/android/android-ndk-r11c/toolchains/x86_64-4.9/prebuilt/darwin-x86_64/bin/x86_64-linux-android-nm --dynamic ./libhellocpp.so | grep "nativeInit"
000c5099 T Java_org_cocos2dx_lib_Cocos2dxBitmap_nativeInitBitmapDC
0008ad25 T Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit
You should use change the file path to your local path.
I am trying to run this command but its not working… I am having similar kind of issue
JNI DETECTED ERROR IN APPLICATION:jmethodID was NULL
in call to CallObjectMethodV
from java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String)