Android JS binding - ExceptionInInitializerError

Hello there,

I have a basic problem with setting up an Android project with JS binding. I use Mac OS X and follow this tutorial:

But I keep getting the ExceptionInInitializerError. Obviously the library is not linked properly. I’ve built the project with build_native.sh, everything shall be ok. I’ve set variables in Android.mk like this:
ANDROID_NDK_ROOT=“/Users/miroslavkutak/Documents/Android/android-ndk-r8e”
COCOS2DX_ROOT=“/Users//Users/miroslavkutak/Documents/Cocos2D/cocos2d-x”
NDK_ROOT_LOCAL=“/Users/miroslavkutak/Documents/Android/android-ndk-r8e”
ANDROID_SDK_ROOT_LOCAL=“/Applications/Android/sdk”

Any idea what am I doing wrong? I just wanted to run cocos2dx/JS hello world on Android.

thx in advance

Did you test it on device or simulator?

James Chen wrote:

Did you test it on device or simulator?

Both device and simulator. Device - Samsung Galaxy S2 with Android 4.1.2, simulator Android 2.2 and 4.2.2

Cocos2D-x latest commit: 306ff0a3fcecaca023660b1abe07c083ad48bb0b

Did you do a ndk build to compile cpp sources? And did .so file exist?

James Chen wrote:

Did you do a ndk build to compile cpp sources? And did .so file exist?

Yes, I have both armeabi and armeabi-v7a folders with libcocos2djs.so. Well this is a result of running build_native.sh, so it shall be ok, I guess.

Well this is a result of running build_native.sh, so it shall be ok, I guess.

Executing build_native.sh only build cpp codes, do you mean that it could generate ExceptionInInitializerError?
Could you provide more information about that?

James Chen wrote:

> Well this is a result of running build_native.sh, so it shall be ok, I guess.
>
Executing build_native.sh only build cpp codes, do you mean that it could generate ExceptionInInitializerError?
Could you provide more information about that?

I get ExceptionInIntializerError when I’m trying to run the app (device/sim). The code is compiled, java is deployed, apk transfered to the (device/sim). So the exception is raised during runtime.

I’ve fixed the problem, but still don’t quite know how. The only thing, that I’ve changed were the paths to NDK and Android SDK in create_android_project.sh. Still the (multiplatform) project was build again with create_project.py.

Now it works like a charm.

But create_android_project.sh can’t generate jsb project. Were there any references of it?
Miroslav Kuťák wrote:

I’ve fixed the problem, but still don’t quite know how. The only thing, that I’ve changed were the paths to NDK and Android SDK in create_android_project.sh. Still the (multiplatform) project was build again with create_project.py.
>
Now it works like a charm.

No. I have really no clue then. You may delete the thread, I woun’t be probably able to retrace the source of a problem.

Thank you for help.