5

I've successfully ported my game to Cocos2d-x and it runs great on Linux, QNX, iOS and Mac. I've also setup the Android NDK and am able to successfully build and run the App on Android (all from the exact same sources, which is really neat !)

On Android there is however one strange thing happening: the SimpleJSON.cpp class I'm using is unable to parse correctly formated JSON strings. Im using this framework: https://github.com/MJPA/SimpleJSON

I've looked into the code, but I'm not much of a CPP expert to see what's (if any) wrong with it (it works on all platforms except Android and it compiles just fine).

I did notice the Class makes use of wchar_t quite extensively and I also understand that that might be a problem on Android.

Anyway I've been figuring out how to get this thing to work for the last 48 hours, but I failed miserably. Is there anyone out there that can point me in the right direction ?

Is there a compiler option that I forget to set ? Is this class just not going to work on Android ? How can I change the class to get it to function properly on Android also ?

All hints are welcome.

Rgds.

  • Please post the code for SimpleJSON.cpp or are you talking about the JSON.cpp that you can find if you follow your link? – john Sep 09 '12 at 09:51
  • Thanks. I was indeed talking about the JSON.cpp and JSONValue.cpp files that can be found in the github repo. I've been looking around in the Android includes and it appears that the wchar.h implementation is just cosmetic (it's a remap to char). I changed all references in the JSON classes from wchar to char and from wstring to string. I'm still testing the changes but it appears that this solves my problem (ar least on Android JSON strings get parsed correctly). I still have to test the changes on the other platforms though (but I don't expect any surprises there). – TomBombadil Sep 09 '12 at 14:09
  • 4
    For future reference: this is the comment in wchar.h: IMPORTANT: Any code that relies on wide character support is essentially non-portable and/or broken. the only reason this header exist is because I'm really a nice guy. However, I'm not nice enough to provide you with a real implementation. instead wchar_t == char and all wc functions are stubs to their "normal" equivalent... – TomBombadil Sep 09 '12 at 14:14
  • `If building for Android and using Visual Studio, make sure Ignore All Default Libraries is set to No. The setting can be changed by going Settings -> Configuration Properties -> Linker -> Input.` Have you done that? – user1095108 May 13 '14 at 15:02

1 Answers1

0

Make sure to use the latest framework. Also look for #if defined(ANDROID) in the code, maybe there's a bug when compiling for Android.

Oren Bengigi
  • 994
  • 9
  • 17