I made a cordova project and device ready worked, I didn't get any errors. Then I tried to add two javascript files and a folder full of images. I have linked them in the index.html and didn't delete anything.. Now Device Ready does fire? Note: I am using Xcode and developing a game for iOS and Android.
Here is the HTML:
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Badger Hop</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="phaser.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
One Javascript file can be found here: http://pastebin.com/QmpCUSA5 (main.js). The other file is Phaser.Min.js (found here: https://github.com/photonstorm/phaser/blob/master/build/phaser.min.js )
In your main.js
file I can't find any deviceready
event handler.
Your app should wait this event before using any cordova function. You should wrap your app initializing function with a code like this:
document.addEventListener('deviceready', function () {
console.log("Start App");
// call your app init function
}
For a more clear example see the Cordova hello world app .
Does your js/index.js
contains this code? Check it.
Solved it.. I renamed the project after I put all those files in, turns out you can't do this. I changed the name back to what it was before and now it works!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.