Black screen when exporting // Fixed/solved

Hi there,

When I compile for Android using Intel or Cocos, I have only a black screen with my application.
It works in preview mode and export to web (but not with optimize and minimize)

However, I’ve tried copying the www folder from Intel exported application to xampp, and in that case I’m getting a black screen in browser as well.

Here’s an error which chrome gives: “Uncaught TypeError: Cannot read property ‘localStorage’ of undefined
at code.js:4”

Any idea what might be causing the issue? It doesn’t seem to happen with some sample applications (they work both with intel and cocos) or when I delete most of my sprites.

The project has 7 objects (one for background, 4 animated units each using 360 small png images for 360 deg angles, one text object, and one animated “bulllet” object using only a few frames).

“Enemy” and “Bullet” objects are placed in 2 groups.

Used extensions are Text object, Pathfinding behavior, Draggable Behavior, and Destroy Outside Screen Behavior.

Removing extensions and events didn’t seem to fix the issue, but removing all objects except background did.

As for events, there are 2 external events used. One to control player NPC and bullets and one to control Enemy objects. Local variables and object groups are used in order to make the game design simple and effective.

Any idea how to potentially solve the issue? Thanks!

Are you using storage actions ?

Thanks a bunch for your reply.

I haven’t used any local storage actions (only local object variables for temporary storage inside of the game, such as HP, Bullet damage, fire speed, etc)

I will try to get more testing done today, and let you know what helps (=makes game load without black screen), and what doesn’t (black screen). Perhaps after we can single out the main cause, someone can offer a solution. I’ve spent a bit of time getting cocos to work (tip make sure to restart windows after setting environment variables, make sure that JDK NDK and other paths are properly set, easiest to do it manually), only to find that my game doesn’t work either with cocos or intel export options.

Edit: Export to web and minify seems to not work also at this moment (testing in xampp localserver after export). This is the easiest to test, so I will use it as initial testing method (easier than saving apks or etc).

What currently doesn’t work (black screen, no loading bar either):

  • Export to web with minify, testing with xampp on Windows.

Reported errors:

Uncaught TypeError: Cannot read property 'localStorage' of undefined at code.js:4 code.js:3 Uncaught TypeError: Cannot read property 'variables' of undefined at new gdjs.RuntimeGame (code.js:3) at 127.0.0.1/:37 at 127.0.0.1/:50 127.0.0.1/:1 Error in event handler for (unknown): TypeError: Cannot read property 'state' of null at CSRecorder.onQueryStateCompleted (chrome-extension://cplklnmnlbnpmjogncfgfijoopmnlemp/content_scripts/recorder.js:106:17)

  • Export to web with Cocos 2D, testing with xampp on Windows

Reported errors:

Failed to load resource: the server responded with a status of 404 (Not Found) cocos2d-js-v3.10.js:1 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/. _loadTxtSync @ cocos2d-js-v3.10.js:1 cocos2d-js-v3.10.js:11 Cocos2d-JS v3.10 box2d.js:4 pre-main prep time: 0 ms main.js:2 Uncaught TypeError: Cannot read property 'isNative' of undefined at Object.cc.game.onStart (main.js:2) at Array.<anonymous> (cocos2d-js-v3.10.js:1) at cocos2d-js-v3.10.js:1 at Object.<anonymous> (cocos2d-js-v3.10.js:1) at HTMLScriptElement.<anonymous> (cocos2d-js-v3.10.js:1) cocos2d-js-v3.10.js:8 Uncaught TypeError: Cannot read property 'config' of undefined at calculateDeltaTime (cocos2d-js-v3.10.js:8) at c.drawScene (cocos2d-js-v3.10.js:8) at c.mainLoop (cocos2d-js-v3.10.js:8) at a (cocos2d-js-v3.10.js:1) 127.0.0.1/:1 Error in event handler for (unknown): TypeError: Cannot read property 'state' of null at CSRecorder.onQueryStateCompleted (chrome-extension://cplklnmnlbnpmjogncfgfijoopmnlemp/content_scripts/recorder.js:106:17) cocos2d-js-v3.10.js:4 Uncaught TypeError: cc.isFunction is not a function at Object.getHTMLElementPosition (cocos2d-js-v3.10.js:4) at HTMLCanvasElement.<anonymous> (cocos2d-js-v3.10.js:4) (The last line repeats a lot)

What currently works (displays image properly):

  • “Preview” option in browser
  • Export to web withoutminify, testing with xampp on Windows.

Thank you for that help. Gonna try to fix this. :slight_smile:

The second error is not representative as you run something designed to run with Cocos js on a standard webserver, so it can’t find some cocos js related object (causing the undefined error).

Forget the previous reply, I misunderstood the way it works. :blush:

Thanks a lot. Because some other projects work (and so does mine if I remove all except background object), I will continue testing and try to single out the actual cause if possible.

As for cocos, yes, it should also work with a local webserver according to the guide (and it does, just not with this project).

Edit: I may have located the problem on my side. Please wait before checking into this.

Edit2: Problem solved. I found that one object (bullet) was using “Physics” extension, but I’ve removed this extension from the project itself (it wasn’t actually used, left over from some testing).

This was definitely a problem on my side. It would be nice if possibly a check can be added to Gdevelop before export, to make sure that all extensions used by objects are enabled in project (or perhaps perform the check when “disable” is attempted).

A second thing I noticed, the project works fine compiled with Cocos 2D (Hint, I used this command to compile: cocos compile -p android --app-abi armeabi, important because cocos will sometimes try to use a different platform and make an error), but there is no loading screen on Android (black screen until loading is finished. Could a (hopefully with ability to customize image/logo) loading screen be added in Gdevelops future? Or maybe this was on my Smartphone. I’m using Android 4.4 and app was compiled with automatically detected target 10 (I think that is 2.33 minimum).