Images on Android not working?

Cocos Code IDE 1.0.1
cocos studio 2.0 beta0
cocos2d-x 3.3 rc0

I created a scene with cocos studio 2.0 and it works on windows very well.
I tried it on my android-device but no images are displayed. Only the labels are shown.
My smartphone has android 4.4.4 and the apk was api 10 and 19.

Any ideas?

My guess is something related to the resource folder isn’t been updated/packaged.

Inside of apk:

apk\assets\res\assets\ships\shuttle\shuttle.png

Scene.csd

 assets/ships/shuttle/shuttle.png

I don’t know if android starts looking in apk\assets\res\ folder.

@nite You were right! The path was wrong. I manipulated the assets directory in proj.android before it was packaged as apk. Pictures are shown now.

I am sure that I found the problem. The Scene.scb tries to find

 assets/ships/shuttle/shuttle.png

The shuttle.png is located in

assets\res\assets\ships\shuttle

The picture is shown when I copy it to

 assets\ships\shuttle

This can be easily fixed!

Open the build-cfg.json and add

 ,
  {
        "from": "../../../res/assets",
        "to": ""
  }

All the /res/assets (cocos studio saves the used assets there) will be copied into the root-directory (which is assets).

any news? The fix only helps when building an APK, debugging via cocos code IDE isn’t working because stuff isn’t copied to the device.

You mean debug with code ide on the device not working?

Yeah it’s not working.
To be precise: It is working, but the images aren’t there.

I am new to Cocos2d-x, and am actually using the Javascript bindings so I may be completely missing something. I have also never built an Android app before so this is a learning/hacking experience. To be clear though, I have everything working perfectly fine on iOS, I am only having issues on Android.

I started logging out from CCFileUtils-Android.cpp to try and figure out whats going on. It seems like there is some funny business going on when the FileUtils class looks for images on Android. The ‘Search Resolution Paths’ and ‘Search Paths’ only appear to be respected when dealing with .ccbi files.

In my project-cfg.json file, I copy 4 different versions of my images assets into 4 different “root” folders. I have a phone, phonehd, tablet, and tablethd folder.

If I duplicate my ccbi’s across all 4 folders, and setup my search path at runtime to one of them, then Cocos2d-x can find the ccbi files.

For example:

  1. If loaded on a phone, the search path gets set to ‘phone’.
  2. If I log out the output of the ‘findFullPathForFile’ method, it finds the scene at ‘phone/MainScene.cbbi’. But when it runs on any of the image files, all that is returned is ‘background.png’, which means it couldn’t find the files.

It looks like the search paths are never being respected when images are loaded on Android. Either that or the images are moved to a completely different place on Android. Are we just missing something here?

At first: How do you publish your game to android? Are you using cocos code ide and debug option or are you building an apk? If you build an apk, open it with 7zip and look at the files. You can check if they are where they should be.

I figured out my issue, which may be the same as yours.

My images were being stored in a subdirectory called Assets. This is the same name as the “resources” folder on Android. So all of the images relative paths looked like ‘assets/imageFile.png’.

The FileUtil cuts the ‘assets/’ part of the path off.

I simply changed the subdirectory name to ‘assetsForGame’ and republished from CocosBuilder, then all of my images loaded.

I have same problem with Michael
And I don’t know how to solve that, pls help :frowning:
I’m using cocos studio 2.3.3 (lastest version) to make UI and export to csb files (path export is “Resources”)

When I build it on android,sprite or image be invisible (but resource of button is working)

Look at the debug output in your logcat. It will tell you the path of the images the engine tries to load.