CRASH ON ANDROID : Unable to get data (GamePlayBg.png) from asset..when running on Emulator.

CRASH ON ANDROID : Unable to get data (GamePlayBg.png) from asset..when running on Emulator.
0.0 0


Hi Every one.

First of all thank you for providing such a great platform to work on android.

My Problem:

After working hard for last two months i completed a game of TRON on win32 using cocos2d-x which is running very perfectly on windows.
then i decided to port the game on android. So started as…

I am using cocos2d-1.0.1-x-0.9.1.
I unzipped it in “g” drive. and renamed the folder as cocos2d-x. so my root directory is > g:/cocos2d-x
I have android-ndk-r6 in “e” drive ie, e:/android-ndk-r6/
I have cygwin 1.7 installed perfectly.
I have default .mk files that came with cocos2d-1.0.1-x-0.9.1.
Now i tried making HelloWorld to run on android and my paths are…
It got compiled with cygwin and build all .so files and after exporting it on eclipse it was working fine but there was orientation problem so i researched over net and found solution to fix it as…
// OpenGLView initialized in on ios platform, nothing need to do here.
>setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // I Just added this line here and orientation was fixed……

Now i have HelloWorld running perfectly fine on emulator and i m able to run tests also on emulator…so far so good.

Now i tried doing the same thing with my Tron Game but it was not getting compiled through cygwin (may be because of paths in So i added all my game class files to the HelloWorld Classes and modified AppDeligate as:

// create a scene. it’s an autorelease object
CCScene pScene = MainMenu::constructScene;
// run
and i got my game running perfectly fine on windows from HelloWorld project…every thing is fine till here.
Now i thaught if HelloWorld alone was working on android fine so it should also work.
So i modified the file in G:2d-x\HelloWorld\android\jni\helloworld as,
include $
LOCAL_MODULE := helloworld
LOCAL_SRC_FILES := main.cpp …/…/…/GameController.cpp …/…/…/MainMenuScene.cpp …/…/…/GamePlayScene.cpp …/…/…/Grid.cpp …/…/…/Tile.cpp …/…/…/Tron.cpp …/…/…/AppDelegate.cpp
LOCAL_C_INCLUDES := $/…/…/…/…/cocos2dx $/…/…/…/…/cocos2dx/platform $/…/…/…/…/cocos2dx/include $/…/…/…/…/cocos2dx/lua_support $/…/…/…/…/CocosDenshion/include $/…/…/…
# it is used for ndk-r5
# if you build with ndk-r4, comment it
# because the new Windows toolchain doesn’t support Cygwin’s drive
# mapping
LOCAL_LDLIBS := ~~L$/…/…/libs/armeabi) ~~lcocos2d lloglcocosdenshion ~~L$/…/…/…/…/cocos2dx/platform/third_party/android/libraries)~~lcurl
include $
and kept everything as it is.
now as yo can see my cpp files, i have 6 classes apart from AppDeligate.cpp and the execution takes place as follows,
AppDeligate.cpp starts running MainMenuScene as : CCScene
pScene = MainMenu::constructScene(); , pDirector->runWithScene(pScene);

and MainMenuScene.cpp displays two button “Start Game” and “Exit”. Now when you click on “Start Game” the execution goes like this,

and i get my GamePlayScene running . This scene runs my whole game which runs perfectly fine on windows. So in my game i have only two scenes MainMenuScene and GamePlayScene and the game is working fine on my PC.

Now coming back to android…
the same way i compiled my game as HelloWorld using cygwin 1.7 and got all .so files.
i exported the game on emulator using eclipse (Indigo)…and…

but every thing goes down when i click on “StartGame”…
As I clicked on “StartGame” the scene is suppose to change from MainMenuScene to GamePlayScene…and i think it started to change…but suddenely it got crash by sayin…

UNABLE TO GET DATA (GamePlayBg.png) FROM ASSETS. and exits to emulators main screen.

i rebuilded the project/recompiled in cygwin/refreshed eclipse completely/build fresh .so and apk file…and tried again two three times but nothing happened same bud…
I tried using GamePlayBg.png in my first MainMenuScene as background (in place of “MainMenuBg.png”). so in first the GamePlayBg.png is coming in first scene (MainMenuScene) as background but as soon as click on “Start Game” button same bug comes again.

i checked the .apk in winRAR and all the resources are present there needed in the game.

I m not able to understand that it is able to add GamePlayBg.png in the first scene but crashes when tried to add the same sprite in second scene…why is that.

I want to have my game on android…Please help me this is the last thing in my game.

With Regards,
Neeraj Singh

My Game Crashed on android when changing scene

Just a guess:

Check folder android/assets to see whether your images are there.

There was (is?) a bug in cocos2d-1.0.1-x-0.9.1 package:


My Blog
Follow me on Twitter
My Site


If your problem is because there is no file into assets folder open


and change line 6 from




By the way, it’s a good idea to do the same for <PATH TO COCOS2DX>/templates/android/


My Blog
Follow me on Twitter
My Site


I am Really very thankful to you that you replied.

Yes i checked my asset folder all images are there and in my .apk (in WinRar) package also all images are there…

but yesterday what i did, I modified the the fresh new HelloWorld code to have only two scene with a button in each scene to toggle b/w these two scene.
I ported this .apk on emulator and i was able to toggle b/w the scene.
and then after that i added MainMenuBg.png in first scene and GamePlayBg.png in othe second scene…now this time i am able to switch b/w the scenes on emulator without any crash.

so i think previously i had just copy pasted my class files to the HelloWorld folder and from VC2010, i did “HelloWorld~~>add~~>existing item.” (from the solution explorer).
and after few modification in code i ran my whole game from HelloWorld…Might me this is why it was crashig…

Now today i’ll be adding codes from my game to HelloWord lets see if that works…(I’ll not add class files directly i’ll create class file and will add code to it).