[Solved] How to solve black screen after package to apk/ipa with Cocos Code IDE 1.2.0?

The black screen happen only package to apk/ipa file with Cocos Code IDE.

  1. App can be opened, no crash but only show black screen.
  2. The project can build simulator runtime and debug with no problem.
  3. Web version can run fine without problem.

I try use adb logcat but show nothing error.

I/Timeline( 1449): Timeline: Activity_launch_request id:zinitter time:15429347
I/ActivityManager( 1147): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=zinitter/org.cocos2dx.javascript.AppActivity bnds=[571,390][763,582]} from pid 1449
I/ActivityManager( 1147): Start proc zinitter for activity zinitter/org.cocos2dx.javascript.AppActivity: pid=30076 uid=10159 gids={50159, 3003, 1028, 1015}
D/dalvikvm(30076): Trying to load lib /data/app-lib/zinitter-1/libcocos2djs.so 0x42edc038
D/dalvikvm(30076): Added shared lib /data/app-lib/zinitter-1/libcocos2djs.so 0x42edc038
I/ActivityManager( 1147): Displayed zinitter/org.cocos2dx.javascript.AppActivity: +486ms
I/Timeline( 1147): Timeline: Activity_windows_visible id: ActivityRecord{43511a10 u0 zinitter/org.cocos2dx.javascript.AppActivity t38} time:15429859

Any idea why black screen happen and how to solve it?

Thanks.

I also encountered the same problem a while ago. Still no luck (althought I have found a few other possible causes for the issue and listed them there).

@ZippoLag

I have solved the black screen problem by put all js files in “src” folder.

My problem is caused by the “Link Source” function to share common js files across projects.
So in the project.json “jsList”, the shares js files are not define under “src” folder but in a different name folder.

After compiled, the “shared” folder is not included. If want run the project in web, i have to copy the “shared” folder and put under the project folder root.

Original which has black screen problem

"jsList": ["src/app.js","shared/shared.js"]

Solution

"jsList": ["src/app.js","src/shared/shared.js"]

I’m not sure is it all the source js files must put in “src” folder or i can put in other folder, then just manual add the folder to compile.

I can see the “shared” folder is not added into the Xcode project when i add it in Cocos Code IDE.
But the “src” folder is added by reference which is a blue color folder.
So all the files in “src” folder will auto included in project.

For Android, may be we need to manual add “copy” folder to “build-cfg.json”

@pandamicro
Can you clarify that we must put all js files in “src” folder or can we put them in other folder?

I understand that for easy, just put all in “src”. But i want to know does the system designed only to load from “src” folder or not.

Thanks.

Interesting find.

Sadly, it seems that’s not whats causing mine to break.

@ZippoLag

Have you try compile the test case project?

The test case project can be compiled and run properly, so i can confirm problem is on my project.
Try step by step to troubleshoot the real problem.

I have read a post that @pandamicro stated that normally black screen is caused by missing file in the project.

Do you modify or add any library to the Cocos2d-JS engine?

I didn’t modify anything from the libraries…

Though I do get a “cocos2d: fullPathForFilename: No file found at script/jsb_boot.jsc. Possible missing file.” in all of my projects (even the ones that work fine when compiled) when running them in Cocos Code IDE for win32.

I have the same error too but it seem can be ignored.

Have you try compile your project on other computer?
From your other post, it may caused by Cocos Code IDE or environment is not setup properly.

This is not the issue, it’s normal that it can’t find jsb_boot.jsc, but it will automatically find jsb_boot.js. you can ignore this message.

You got the point, if anything that you needed is not in the src/ or res/ folder, you need to manually add a section in copy_resources of build-cfg.json. This is the solution for android. As for iOS, you simply put them in your xcode project.

1 Like

Thanks for your reply.

Must we copy the file to src/ folder?
In Xcode, we must drop the extra sources folder to src/ too?

    {
        "from": "../../../shared",
        "to": "src"
    },

or 2.

    {
        "from": "../../../shared",
        "to": "shared"
    },

You should use 2, because you will reference your shared resources int the code like this : shared/xxx.js
It’s just a matter of finding it in the published folder

As for iOS, just put it as resources into the project so that it can be found by xcode, no other rules

Ok thanks for your time on explanation!

With pleasure

1 Like