PDA

View Full Version : PhoneGap object is not created in production build



rbahumi
6 Nov 2012, 2:08 AM
REQUIRED INFORMATION

Ext version tested:

Sencha Touch 2.1.0-rc2
Browser versions tested against:

Chrome Version 22.0.1229.94 m (Windows 7)
Safari 5.1.7 (Windows 7)
DOCTYPE tested against:

DOCTYPE html
Description:
Trying to combine Sencha Touch with PhoneGap, the phonegap object is not created on a production build (CMD: 'sencha app build production').

Running the application in dev mode (before running any build) works just fine, and the 'PhoneGap' object is created.
The testing build also works.
When trying to run the production build, the PhoneGap 'deviceready' event is never fired, and the PhoneGap object is never created.
Steps to reproduce the problem:

Create a new app:

sencha app generate testapp ..\testdir
Edit the 'js' array in app.json, and add the cordova Android JS file:


"js": [
{
"path": "sdk/sencha-touch.js"
},
{
"path": "cordova-2.2.0.js",
},
{
"path": "app.js",
"bundle": true, /* Indicates that all class dependencies are concatenated into this file when build */
"update": "delta"
}
],

Creating testing & production builds (CMD: 'sencha app build testing\production )
Running both builds in a Chrome browser, and typing 'Phonegap' in the Chrome Dev Console for both. The 'testing' build will present the 'Phonegap' object, while in the 'production' it is undefined.
The result that was expected:

There should be no difference between 'testing' & 'production' builds on this metter.
The result that occurs instead:

Running both builds in a Chrome browser, and typing 'Phonegap' in the Chrome Dev Console for both. The 'testing' build will present the 'Phonegap' object, while in the 'production' it is undefined.
Test Case:
As described above in the 'Steps to reproduce the problem' section.


HELPFUL INFORMATION

All the belows were tested with when trying to integrate the Android JS file (both cordova-2.1.0.js & cordova-2.2.0.js) on Chrome, Safari and also on HTC Nexus 1 (Android 2.3) and HTC 1 X (Android 4)

Operating System:

Win 7 Pro

rbahumi
11 Nov 2012, 11:33 AM
Are there any updates?
Did anyone from the Sencha team take a look at this issue? Did you manage to reproduce it, or am I the only one experiencing this?

Please replay, even if there is no solution available.
Roei.

rbahumi
12 Nov 2012, 2:31 AM
Workaround:

Please note that there is a workaround for this issue, if you add the cordova JS file manually to the index.html file :



........
<!-- The line below must be kept intact for Sencha Command to build your application -->
<script id="microloader" type="text/javascript" src="sdk/microloader/development.js"></script>
<script type="text/javascript" src="cordova-2.2.0.js"></script>
</head>


This is in addition to including the file in the app.json file:


"js": [
{
"path": "sdk/sencha-touch.js"
},
{
"path": "cordova-2.2.0.js",
"remote": true
},
{
"path": "jquery-1.8.2.min.js",
"remote": true
},
{
"path": "app.js",
"bundle": true, /* Indicates that all class dependencies are concatenated into this file when build */
"update": "delta"
}
],


Please also note, that adding the cordova JS file manually to the production index.html also works ( after the 'sencha app build production' command). Therefore, (and I assume that with a very modest knowledge regarding the Sencha Touch Core ) the problem is probably with the process of automatically loading the script. This assumption is particularly weird for me, because the jquery's JS file loads normally.

I hope that this may help locating the root cause of this issue.