-
21 Mar 2012 12:13 PM #1
Unanswered: Ext.setup has already been called before when using Phonegap 1.5 on Android
Unanswered: Ext.setup has already been called before when using Phonegap 1.5 on Android
I am using Sencha touch 2 and Phonegap 1.5, and try to package and deploy to Android 2.2. I got this error:
Ext.setup has already been called before.
I use sencha-touch-debug.js and have a block of code in app.js like:
Ext.setup({
...
onReady: function() {...}
});
Could anyone shed some lights on what is causing this?
-
21 Mar 2012 12:41 PM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28
- Answers
- 83
I would call your ST code within onDeviceReady();
That said, you should not be using Ext.setup, rather Ext.application();
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
21 Mar 2012 12:54 PM #3
Could you elaborate on where does onDeviceReady() reside? Could you post some sample codes?
-
21 Mar 2012 4:03 PM #4
Eugene
Ext.Direct for ASP.NET MVC
-
22 Mar 2012 5:35 AM #5
My app.js used Ext.application ({...}); initially without phonegap in the picture. Since I need to package phonegap to take advantage of their support of native API, I refered to the article you mentioned to integrate. I used
document.addEventListener(ondeviceready, app.mainLaunch, false). But it complains that cannot find "app" object.
Then I read an article which suggests use Ext.setup ({ onReady: function() {...}) to wrap around Ext.application({...}).
That is the history of my taking the route of using Ext.setup.
If use your suggestion, how do I get around the issue of "cannot find 'app' object" when in index.html I use document.addEventListener(ondeviceready, app.mainLaunch, false) ?
Many thanks for the help and be patient, I am new to this space.
-
22 Mar 2012 6:24 AM #6
Is 'app' the actual name of your application? Hmm... Anyways, you app object doesn't exist at this point yet. Call it like this:
Code:document.addEventListener("deviceready", function () { app.mainLaunch(); }, false);Eugene
Ext.Direct for ASP.NET MVC
-
22 Mar 2012 6:58 AM #7
I finally follow this thread and make it work:
http://www.sencha.com/forum/showthre...=ondeviceready
In general, here are the keys that save me:
(1) For PhoneGap 1.5 and ST 2.0, there is no need for setting up ondeviceready or onready events. ST2.0 handles it nicely when using 'Ext.application({...}).
(2) in index.html, phonegap js needs to be at the top.
(3) use sencha-touch-all.js instead of using others.
Thanks for all the helps and suggestions!
-
22 Mar 2012 7:34 AM #8
Oh, wow... I did not know that. Thanks!
Eugene
Ext.Direct for ASP.NET MVC


Reply With Quote