CCUserDefault crash on Android?

CCUserDefault crash on Android?
0.0 0



I am porting a game from iOS to android use cocos2d-x, and I want to find a replacement to NSUserDefaults.

After a few try, I found the CCUserDefault seems to be my answer.

When I call something like this : “CCUserDefault::sharedUserDefault()->setIntegerForKey(”egg_num“, 1);” on android, it just crash.

But this is fine at iOS build. Can somebody help me about this issue?

Thank you.



I found there is a same issue posted before(

I will wait for a new build to fix this bug.

Or do you guys have another way to do the same thing?

Thank you.


I am experiencing the same problem, but for me its CCFileUtils::getWritablePath() that actually crashes (simulator and actual device).
I can easily reproduce it by just generating a template android project, and adding the above line anywhere.


to Steve S:
CCFileUtils::getWritablePath() crash bug has been resolve in the latest code, and 0.9.2 will be published within a few days


to Steve S:
CCFileUtils::getWritablePath() crash bug has been resolved in the latest code, and 0.9.2 will be published within a few days


Awesome, thanks for the fast response!
Tried to checkout the latest via:

$ git clone
Initialized empty Git repository in …/test/cocos2d-x/.git/
fatal: download error - The requested URL returned error: 403

Am I using a bad url for the repo?


ye, the url is right :

did you download the cocos2d-x code from github before?

you could try if you could enter the page
or maybe you need a github account.


Got it :slight_smile:
git clone —depth 1 git://
worked for me.


Ok, rebuilt my project against the latest sources, and CCFileUtils::getWritablePath() now works as expected.



Can you give me a more detail instruction about how to change current version cocos2d-x to this version?

I need this to make my android porting progress continue.

Thank you in advance.


you could use git to download the source code from or git://,
or you could enter and click the download button on the upper-right corner to download the source code.

then you could put your own project things in the corresponding position in the -x directory or you could directly replace the engine code of your project with the downloaded code.

btw, the setXXXForKey() bug has been resolved.



Thank you for your help, I am using this new version smoothly.