JSON.parse error in Android

My game is working good into the web-browser, even into mobile Chrome it has worked. I start to prepare it to deploy Android and iOS versions!
To do so I am fixing several bugs:

cc.setScale gets to arguments into HTML5 (but works with just one), and it crashes the games if using 2 arguments into the Binding.

To create a cc.MenuItemSprite, I need to pass the selected and the disable images, otherwise: crashes.

Now my bigger problem, in my game I load some data from a JSON file, just like this:

var questionFileString = cc.FileUtils.getInstance().getStringFromFile(s_QuestionJSONFile);
this.questionDictionary = JSON.parse(questionFileString);

Nevertheless it is given the error in logCat:
D/cocos2d-x debug info(22113): “…” SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data

Have tried many things, but could not fix it until now…

Anyone?

Thanks!

I think the latest release resolved this issue. Did you try that?

@James Chen!

Yeah, indeed the latest release has solve the issue! Thanks!

Unfortunately the JSB is broken now. I can deploy the apks (in Android), but was not able to play the game (not even the MoonWarrior example).

What’s the error?

Pedro Kayatt wrote:

@James Chen!
>
Yeah, indeed the latest release has solve the issue! Thanks!
>
Unfortunately the JSB is broken now. I can deploy the apks (in Android), but was not able to play the game (not even the MoonWarrior example).

I think you already have seen it at the main page, but here we go:

The crash that I could get was:
Crash dump: **
Build fingerprint: ‘google/takju/maguro:4.2.2/JDQ39/573038:user/release-keys’
pid: 8016, tid: 8061, name: Thread-3708 >>> org.cocos2dx.moonwarriors <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000014
Stack frame #00 pc 006e2480 /data/app-lib/org.cocos2dx.moonwarriors-2/libmoonwarriors.so (cocos2d::CCString::initWithFormat(char const, …)+35)
Stack frame #01 pc 0018df81 /data/app-lib/org.cocos2dx.moonwarriors-2/libmoonwarriors.so (ScriptingCore::runScript(char const, JSObject**, JSContext**)+116)
Stack frame #02 pc 00187d47 /data/app-lib/org.cocos2dx.moonwarriors-2/libmoonwarriors.so (AppDelegate::applicationDidFinishLaunching()+126)
Stack frame #03 pc 0070266f /data/app-lib/org.cocos2dx.moonwarriors-2/libmoonwarriors.so (cocos2d::CCApplication::run()+6)
Stack frame #04 pc 00187bd3 /data/app-lib/org.cocos2dx.moonwarriors-2/libmoonwarriors.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit+62)
Stack frame #05 pc 0001e290 /system/lib/libdvm.so (dvmPlatformInvoke+112)
Stack frame #06 pc 0004d411 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const**, JValue**, Method const**, Thread**)+396)
Stack frame #07 pc 0004f56f /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const**, JValue**, Method const**, Thread**)+174)
Stack frame #08 pc 000276a0 /system/lib/libdvm.so
Stack frame #09 pc 0002b57c /system/lib/libdvm.so (dvmInterpret(Thread**, Method const**, JValue*)+184)
Stack frame #10 pc 0005fc31 /system/lib/libdvm.so (dvmCallMethodV(Thread**, Method const**, Object**, bool, JValue**, std::__va_list)+272)
Stack frame #11 pc 0005fc5b /system/lib/libdvm.so (dvmCallMethod(Thread**, Method const**, Object**, JValue**, …)+20)
Stack frame #12 pc 000547d7 /system/lib/libdvm.so
Stack frame #13 pc 0000e3d8 /system/lib/libc.so (__thread_entry+72)
Stack frame #14 pc 0000dac4 /system/lib/libc.so (pthread_create+160)

Also in the ADB:

05-02 15:11:50.157: D/dalvikvm(8016): GC_CONCURRENT freed 232K, 3% free 8889K/9156K, paused 5ms+4ms, total 23ms
05-02 15:11:50.391: D/cocos2d-x debug info(8016): Get data from file(MoonWarriors-jsb.js) failed!
05-02 15:11:50.391: A/libc(8016): Fatal signal 11 (SIGSEGV) at 0x00000014 (code=1), thread 8061 (Thread-3708)

It is an error into the execution of the game into the phone. I could only get it with NDK DEBUG, the compilation itself has completed without any errors.

Trying again and I got this clear error:

make: Entering directory `/cygdrive/c/NakedMonkey/tools/cocos2dx/cocos2d-2.1rc0-x-2.1.3/template/multi-platform-js/proj.android’
make: * No rule to make target `/cygdrive/c/NakedMonkey/tools/cocos2dx/cocos2d-2.1rc0-x-2.1.3/cocos2d-2.1rc0-x-2.1.3/template/multi-platform-js/proj.android/…/…/…/scripting/javascript/bindings/ScriptingCore.cpp’, needed by `obj/local/armeabi/objs/scriptingcore-spidermonkey/ScriptingCore.o’. Stop.
make: Leaving directory `/cygdrive/c/NakedMonkey/tools/cocos2dx/cocos2d-2.1rc0-x-2.1.3/template/multi-platform-js/proj.android’

Not sure what happened, but I got the zip extracted and tried to build from the start…

Ok, that last error has been solved just by deleting the folders BIN GEN and OBJ.

Not sure why it was dirt, anyway, got to test the .so into the device, hold for more info :smiley:

Ok! Got it working!

In fact the error was exactly what @James Chen has spoke about! The Resources were not being copy to the Assets folder for some strange reason.

I still need to figure out what is given the problem of bad permissions or why the script did not has copy all resources to the assets, but I did it through the Windows Explorer and everything works well.

Thanks guys!

Glad to hear that it works now.

Pedro Kayatt wrote:

Ok! Got it working!
>
In fact the error was exactly what @James Chen has spoke about! The Resources were not being copy to the Assets folder for some strange reason.
>
I still need to figure out what is given the problem of bad permissions or why the script did not has copy all resources to the assets, but I did it through the Windows Explorer and everything works well.
>
Thanks guys!