deviceready has not fired in phonegap 2.9.0 with sencha touch 2

十年热恋 提交于 2020-01-13 03:40:11

问题


I use PhoneGap 2.9.0 and SenchaTouch to develop my Android application (targetSdkVersion 16).

When I start the app in Chrome, I got such logs :

Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. cordova.js:912
deviceready has not fired after 5 seconds. cordova.js:6725
Channel not fired: onCordovaConnectionReady cordova.js:6718
Channel not fired: onCordovaInfoReady  cordova.js:6718

When I test it in Samsung tablet (Android 4.1.2), the first line disappeared but the 3 events are always not fired.

However, it seems SenchaTouch works quite good: views display and interactions works as I expect.

Here's the head section of index.html:

 <head>
    <meta charset="UTF-8">
    <title>title</title>

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

    <style type="text/css">
       some css here
    </style>

    <script type="text/javascript" charset="utf-8" src="pg/cordova.js"></script>      
    <script type="text/javascript" charset="utf-8" src="pg/barcodescanner.js"></script>  

 </head>

I use some phonegap API such as Camera and File. As PhoneGap receives never deviceready event, the API is not available so navigator.camera is undefined.

I did a hug research but all I tested does not resolve the problem. Any advice is welcome Thanks in advance


回答1:


Had the same issue, but in my case it was due to the fact that I have referenced plugins in my config.xml which I have not instantiated within my application.

Simply commenting them out until I referenced them in my code gave me an immediate "Phonegap is ready".

Thanks goes to: http://community.phonegap.com/nitobi/topics/deviceready_has_not_fired_after_5_seconds




回答2:


I recommend you to try with a clean not-sencha html, just to trace if the error cames from sencha or phonegap




回答3:


The problem is caused by a hard-coded time out when loading urls. This time-out occurs because the size of the page, generated by Sencha Touch, can't be calculated. Unfortunately I can't find the resources I used to solve this problem in the past, so correct me if I'm wrong, but my solution was to create a html file with a redirect to the actual index.html.

<!DOCTYPE html>

<!-- Launch the generated index.html file to prevent Cordova/PhoneGap timeouts -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>AppName</title>
    <script>
        window.location = './index.html';
    </script>
</head>
<body></body>
</html>



回答4:


According to the iOS 8 Beta 1 release notes (WebKit section), it is a known issue that Cordova/Phonegap apps are currently broken due to a user agent bug.

Applying this temporary "fix" solved my issues with the "deviceready" event not being fired.

https://stackoverflow.com/a/24069550




回答5:


you need to include cordova plugin before closing of body tag, as follows
<!doctype html>
<html>
    <head>
    </head>
    <body>

        <script src='cordova.js' type='text/javascript'></script>
        <script src='index.js' type='text/javascript'></script>
    </body>
</html>


来源:https://stackoverflow.com/questions/17837899/deviceready-has-not-fired-in-phonegap-2-9-0-with-sencha-touch-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!