Black screen after packaging to APK

Hello,
i create a simple memory game with the last version of cocos code IDE(v1.2.0) and last version of cocos2d-JS(v3.3) and it work fine on the WEB and also work well when i debug it to an android simulator(BlueStack) and my android device, BUT when i have to debug it on BlueStack the following error appear in the IDE consol: JS: /data/data/org.cocos2dx.PrebuiltRuntimeJs/files/debugruntime/script/jsb_create_apis.js:910:Error: js_cocos2dx_LabelTTF_create : wrong number of arguments so i delete all argument for cc.LabelTTF.create except text, fontName, fontSize to debug the game correctly.

Now, after i get the APK file (result of package the game to apk), i get a black screen that show only the FPS on both BlueStack and my android device.
Note that when i package the default HelloWolrd project it works correctly without this problem.

i use the last version of ant(v1.9.4) and NDK r9d

How can i solve this problem?

thanks in advance.

Are you sure the app can find it’s resources?
What is the adb output? I haven’t use the ide, I run from Eclipse, but there should be a way to see what the adb output is when you run the apk version on the device hooked up throught the usb debugging.

Thanks for your replay.

when running the apk file of the game(the one without doing package to APK) i got this in the console:

Start LaunchActivity org.cocos2dx.PrebuiltRuntimeJs/org.cocos2dx.javascript.AppActivity
debug server : client connected
JS: asyncListen....
cocos2d: fullPathForFilename: No file found at script/jsb_boot.jsc. Possible missing file.
create rendererRecreatedListener for GLProgramState

this one work well and all resources are shown.

but when i debug the apk file generated form package to apk option i just got this line in the console:

Start LaunchActivity org.example.concentration/org.cocos2dx.javascript.AppActivity

and the black screen with the FPS appear on the emulator and android device. so i can’t see what happen.

But i placed the images of this game in the same structure of the default hello world project, so i really don’t know why can’t find the resources since it find the resource of the default hello world poject

That is strange, you have any filter enabled in adb console? I think this dont make any difference but try to use new cc.LabelTTF() instead of the decrapted create method.

You can check out YOUR_PROEJCT_FOLDER\frameworks\runtime-src\proj.android\build-cfg.json to see if all your assets are in the folders described in copy_resources tag.

Open your apk with a file archiver of some sort and check if all your assets are in there.

thanks for you reply.

this is the content of build-cfg.json file.

{
    "ndk_module_path" :[
        "../../js-bindings",
        "../../js-bindings/cocos2d-x",
        "../../js-bindings/cocos2d-x/cocos",
        "../../js-bindings/cocos2d-x/external"
    ],
    "copy_resources": [
        {
            "from": "../../../src",
            "to": "src"
        },
        {
            "from": "../../../res",
            "to": "res"
        },
        {
            "from": "../../../main.js",
            "to": ""
        }
    ],
    "must_copy_resources": [
        {
            "from": "../../js-bindings/bindings/script",
            "to": "script"
        },
        {
            "from": "../../../config.json",
            "to": ""
        },
        {
            "from": "../../../project.json",
            "to": ""
        } 
    ]
}

and when i unpacked the apk file i found the resources too.

the pictures are in the assets folder.

this is exactly the same structure as the default Hello World simple project created by cocos IDE.
(the only difference is that the default project work after packaging and my game doesn’t!)

also i get this alert box when i want to package to APK. i forgot to mention it in the question before.

I dont have any clue.

Try create a new project with the rigth engine version or even replace the files from the working Hello World example with yours files, don’t forget to add them also in the project.json. To see if apk still works.

I get a similar issue too. I’m using Cocos2D v3.7, NDK r10e, JavaScript. My game runs perfectly fine when I debug it on Chrome (web) but when I try it in the iOS simulator or my android device I get a black screen.

Hi, I have the same problem on Android device.
Did you find any solution? Thank’s!

I’m not exactly sure what I did to fix it, it was a long time ago. I did everything through the command line/terminal on my mac. I stopped using the Cocos Code IDE.

I am having the same issue, when I’m compiling the game for my android device I get black screen but on the web it works fine. Can you please remember what you did to make it work? I have to mention that only when I use code which belongs to the Box2D module, only then I get black screen. If I comment the box2d code everything works again. Please help. Thank you.

This is also an issue for me, with the latest version (3.14). I’m not using Box2D or anything, just a slightly modified default example (cocos sprite in the center of the screen, etc.)

I fixed my error

You have to compile the project for android-studio by
cocos compile -p android --android-studio , then run the project on device and see the output for any errors by selecting the project.
Javascript on the browser is very flexible , I mean we can use a variable without even declaring it but not the same when we run on android , so you need to look at the debug console to fix this issue.