PDA

View Full Version : Production + Package Builds - Breaks with Javascript errors (null & undefined)



tt88
3 Sep 2013, 4:50 AM
Hi

I am getting Javascript errors when running package + production versions of my app.
Some errors are fixable, eg: For a tap event, the button.action was returning null, which I replaced with button.config.action
I'm getting a lot of errors like "Cannot call method 'down' of undefined", "Cannot read property 'x' of null"

What is the reason for this happening? Surely the production versions should work the same as your debug / build version?

Any advice on building a production version?

Cheers
tt88

tt88
3 Sep 2013, 5:22 AM
I found an article that does indicate there are some issues with building a sencha app, recommending not to use production mode:
http://andidog.de/blog/2012/07/dont-use-sencha-touch-production-mode-build-for-mobile/

tt88
3 Sep 2013, 5:41 AM
Delving into the problem deeper, one of the issues seems to be with references in controllers

fmoseley
4 Sep 2013, 7:09 PM
I would suggest that you edit your app.json to use sencha-touch-debug.js, create a testing build (sencha app build testing). And check the console for error and warnings.

babsjr77
23 Sep 2013, 2:03 PM
Using Sencha Cmd (3.1.2.342) with Sencha Touch (2.2.1) has been one frustration after another.

All I want from Sencha Cmd is an app.js (includes all javascript in the proper order and is minified) to package into my cordova application.

sencha app build testing --> This produces an app.js with all my javascript but not minified. I have an index.html which includes this app.js (not using microloader) and cordova.js and it works great.

sencha app build production (or package) --> Produces a minified app.js with missing code. In this case I get an error: touch/src/event/publisher/Dom.js 404 (Not Found). What is sencha cmd doing differently in this case to create a broken app.js?

Kurt001
23 Sep 2013, 10:59 PM
Sorry to say, but you need to understand how Sencha and when Sencha is doing things.

For example the first problem mentioned:

button.action was returning null

if you use lazy instantiation the getters and setters are created for Ext.Button right after loading. Adding a config item "action" like this won't create getters and setters, because it's added too late:


Ext.Viewport.add({xtype:'button', action: 'myAction'});

But if you create your own button and instantiate your own button it works. E.g.:


Ext.define('App.view.buttons.MyButton', {
extend: 'Ext.Button',
xtype: 'mybutton',
config: {
action: 'someAction'
}
});
And then you add it:

Ext.Viewport.add({xtype:'mybutton', action: 'myAction'});

Now it works.
There is a good book explaining it all: Sencha Touch in Action
Grab one, it explains it pretty much in detail.

Most of the problems if read about in this thread are similar problems.

tt88
30 Sep 2013, 12:22 AM
Thanks for the reply and the book reference. At least some of my issues makes sense now. Will definitely check out the book - already have some Sencha books & find they lack in certain aspects. This one has gotten good reviews.

Kurt001
30 Sep 2013, 1:03 AM
Thanks for the reply and the book reference. ... This one has gotten good reviews.
This is definately all you need, once have a certain level of understanding.
It's from the guy who answers most of the questions here in the forum: Mitchell Simoens.
You can see that he definately knows what people need to know. I guess this book has at least 3 years of forum knowledge :D