Require failed on android build

Hi everyone,

I am trying to build an app with Cocos Creator.
When I test my project with the simulator, everything works fine.
But when I build the apk and run it on an emulator or a phone, I am only getting a blackscreen. The logcat tells me that ‘require’ has thrown an error because one of my scripts couldn’t be found.
Does the project needs to follow a certain structure for the scripts to be found?

Thanks in advance,
here is the complete stacktrace which was shown by logcat:

03-12 12:02:17.244  7403  7420 E jswrapper: [ERROR] Failed to invoke require, location: D:/Dokumente/Cocos2D/WhammyChat/build/android/110/22/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../manual/jsb_global.cpp:231
03-12 12:02:17.245  7403  7420 E jswrapper: ERROR: Uncaught Error: Cannot find module 'CustomSettings.js', location: src/project.js:0:0
03-12 12:02:17.245  7403  7420 E jswrapper: STACK: 
03-12 12:02:17.245  7403  7420 E jswrapper: [0]n@src/project.js:11 
03-12 12:02:17.245  7403  7420 E jswrapper: [1]anonymous@src/project.js:18  
03-12 12:02:17.245  7403  7420 E jswrapper: [2]__require.ChatLoader.ColorPalette@src/project.js:803  
03-12 12:02:17.245  7403  7420 E jswrapper: [3]n@src/project.js:17 
03-12 12:02:17.245  7403  7420 E jswrapper: [4]e@src/project.js:23  
03-12 12:02:17.245  7403  7420 E jswrapper: [5]anonymous@src/project.js:25 
03-12 12:02:17.245  7403  7420 E jswrapper: [6]s@src/jsb_polyfill.js:10  
03-12 12:02:17.245  7403  7420 E jswrapper: [7]anonymous@src/jsb_polyfill.js:21 
03-12 12:02:17.245  7403  7420 E jswrapper: [8]o@src/jsb_polyfill.js:19482  
03-12 12:02:17.245  7403  7420 E jswrapper: [9]83.y.handle@src/jsb_polyfill.js:9686  
03-12 12:02:17.245  7403  7420 E jswrapper: [10]r@src/jsb_polyfill.js:10223 
03-12 12:02:17.245  7403  7420 E jswrapper: [11]r@src/jsb_polyfill.js:10241 
03-12 12:02:17.245  7403  7420 E jswrapper: [12]89.c.flowIn@src/jsb_polyfill.js:10289
03-12 12:02:17.245  7403  7420 E jswrapper: [13]86.m.append@src/jsb_polyfill.js:9991 
03-12 12:02:17.245  7403  7420 E jswrapper: [14]79.C.load@src/jsb_polyfill.js:9104 
03-12 12:02:17.245  7403  7420 E jswrapper: [15]prepare@src/jsb_polyfill.js:19209
03-12 12:02:17.245  7403  7420 E jswrapper: [16]run@src/jsb_polyfill.js:19226  
03-12 12:02:17.245  7403  7420 E jswrapper: [17]boot@main.js:187  
03-12 12:02:17.245  7403  7420 E jswrapper: [18]anonymous@main.js:215
03-12 12:02:17.245  7403  7420 E jswrapper: [19]anonymous@main.js:239  

I also had a black screen at build time if I had an error in my script You need to fix that part. Try Developer -> Compile User Script from the menu

So for me it worked when I changed the template to binary (note: I am using v1.10.2).
Still wondering why it only works on binary though.

Hi,
Because I recently switched to v2.0.9, this issue is relevant again as the binary template is not available in this version.

Now it is not because Cocos can’t find my script, but rather just some jswrapper stuff.

This is the only error message I am getting:

05-08 13:13:11.100 31415 31430 E jswrapper: [ERROR] Failed to invoke require, location: D:/Dokumente/Cocos2D/WhammyChat/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_global.cpp:292

I tried to look into the file, but I am not that familiar with c++ and the whole Cocos compiling process to fully understand what is happening and what the error is.

Best regards

I found out that this is not the error that makes my app crash. This is only due to some modules I deactivated because I don’t need them, but the jsb files are passed to the require function anyways. The app itself crashes because of another error, but I will open a new thread for that.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.