I use PhoneGap 2.9.0 and SenchaTouch to develop my Android application (targetSdkVersion 16).
我使用PhoneGap 2.9.0和SenchaTouch来开发我的Android应用程序(targetSdkVersion 16)。
When I start the app in Chrome, I got such logs :
当我在Chrome上启动应用程序时,我得到了这样的日志:
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.
当我在三星平板电脑(Android 4.1.2)上测试时,第一行消失了,但3个事件始终没有被触发。
However, it seems SenchaTouch works quite good: views display and interactions works as I expect.
然而,看起来SenchaTouch很好:视图显示和交互作用正如我所期望的那样。
Here's the head section of index.html:
这里是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.
我使用一些phonegap API,比如相机和文件。由于PhoneGap永远不会接收deviceready事件,所以API是不可用的,所以导航器。相机是未定义的。
I did a hug research but all I tested does not resolve the problem. Any advice is welcome Thanks in advance
我做了一个拥抱研究,但我所做的测试并不能解决问题。任何建议都要提前感谢。
5 个解决方案
#1
5
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.
有相同的问题,但在我的情况下,这是由于我在配置中引用了插件。我在应用程序中没有实例化的xml。
Simply commenting them out until I referenced them in my code gave me an immediate "Phonegap is ready".
简单地把它们注释掉,直到我在我的代码中引用它们,给了我一个立即的“Phonegap已经准备好了”。
Thanks goes to: http://community.phonegap.com/nitobi/topics/deviceready_has_not_fired_after_5_seconds
由于是:http://community.phonegap.com/nitobi/topics/deviceready_has_not_fired_after_5_seconds
#2
0
I recommend you to try with a clean not-sencha html, just to trace if the error cames from sencha or phonegap
我建议您尝试使用一个干净的非sencha html,只要在sencha或phonegap上跟踪错误。
#3
0
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.
这个问题是由于加载url时硬编码的超时造成的。这种超时发生是因为由Sencha Touch生成的页面大小无法计算。不幸的是,我无法找到以前用来解决这个问题的资源,所以如果我错了,请纠正我,但是我的解决方案是创建一个html文件,重定向到实际的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
0
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.
根据ios8 Beta 1发布说明(WebKit部分),目前已知的一个问题是,Cordova/Phonegap应用程序由于用户代理错误而被破坏。
Applying this temporary "fix" solved my issues with the "deviceready" event not being fired.
应用这个临时“修复”解决了我的问题,“deviceready”事件没有被解雇。
https://*.com/a/24069550
#5
0
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>
#1
5
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.
有相同的问题,但在我的情况下,这是由于我在配置中引用了插件。我在应用程序中没有实例化的xml。
Simply commenting them out until I referenced them in my code gave me an immediate "Phonegap is ready".
简单地把它们注释掉,直到我在我的代码中引用它们,给了我一个立即的“Phonegap已经准备好了”。
Thanks goes to: http://community.phonegap.com/nitobi/topics/deviceready_has_not_fired_after_5_seconds
由于是:http://community.phonegap.com/nitobi/topics/deviceready_has_not_fired_after_5_seconds
#2
0
I recommend you to try with a clean not-sencha html, just to trace if the error cames from sencha or phonegap
我建议您尝试使用一个干净的非sencha html,只要在sencha或phonegap上跟踪错误。
#3
0
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.
这个问题是由于加载url时硬编码的超时造成的。这种超时发生是因为由Sencha Touch生成的页面大小无法计算。不幸的是,我无法找到以前用来解决这个问题的资源,所以如果我错了,请纠正我,但是我的解决方案是创建一个html文件,重定向到实际的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
0
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.
根据ios8 Beta 1发布说明(WebKit部分),目前已知的一个问题是,Cordova/Phonegap应用程序由于用户代理错误而被破坏。
Applying this temporary "fix" solved my issues with the "deviceready" event not being fired.
应用这个临时“修复”解决了我的问题,“deviceready”事件没有被解雇。
https://*.com/a/24069550
#5
0
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>