Cocos2dx Android: Get Data From File(assets/*) Failed
Solution 1:
I believe you need to run ./build_native.sh in your android folder before run on Eclipse.
Solution 2:
So the actual problem wasn't with the building or copying process.
I had a class I made that would apply the correct prefix to a CCSprite if it was an iphone, ipad, etc. And I made some changes to the CCMenuItemImage source code to incorporate this file, but the iOS and Android Cocos2dx files are separate, so the Android project wasn't using the new code, and wasn't adding the correct prefix, so it wasn't finding the image.
Thank you everyone for your answers!
Solution 3:
You no need to add to the assets folder , when you run ./build_native.sh it will automatically add to the assets folder. Check it build successfully without any errors and then import to eclipse.
Solution 4:
Try using
const char *path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("testimage.png");
before giving cocos2d-x your filename.
Solution 5:
This was the same problem I face. Actually I have solved this problem by doing:
- Run the ./build_native.sh from cygwin. This step to move the asset needed to android project. Dont forget to chmod 777 -R first to your cocos project, i've got an error because the build_native.sh doesn't have permission to move the assets.
- In eclipse, build it again following this tutorial. In that link, it shows how to build the cpp source + cocos2d in eclipse.
- Run as android application, then the .apk will be generated.
Post a Comment for "Cocos2dx Android: Get Data From File(assets/*) Failed"