Quickstart a Cordova application
This guide uses the Cordova CLI, and is a condensed version of the Apache Cordova Documentation.
- Install any development kits you’ll need to compile for your target platforms;
- Install Node and Git if you haven’t already;
- Install Cordova if you haven’t already, using
npm install -g cordova(
-gmakes it global).
Start an app
Run the command prompt as admin on Windows (File, Open command prompt, Open command prompt as administrator)
Run the following commands using the directory you want to create, a unique namespace you own, and a new app name:
cordova create AppDirectory uk.co.mywebsite.myapp AppName cd AppDirectory cordova platform add wp8 cordova platform add android
…adding a line for any other platforms you want to target. The opposite of
This generated a skeleton directory with some default files. The docs say,
Any initialization should be specified as part of the deviceready event handler, referenced by default from www/js/index.js.
…but I feel like it doesn’t matter. You can wipe out basically all of the HTML, JS, and CSS installed by
cordova create and it still works, but you should preserve the useful directory structure.
Add plugins if you want, specifying a cordova-registered name or a git url:
cordova plugin add phonegap-plugin-barcodescanner cordova plugin add https://github.com/apache/cordova-plugin-console.git
rm to remove
Build and deploy
To build and deploy your current code onto attached USB devices, just type
A breakdown of what this does
This does cordova
compile as pre-requisites, then runs the build on available devices.
preparecopies the latest files across to each platform folder, ready to compile;
compilegets the appropriate compiler (MSBuild, JDK, etc.) to build it into a native app;
buildis an alias command which does both of the above but does not run the project;
If you want to run the existing build without recompiling, use
cordova run --nobuild. For info, try
cordova help run.
Have fun and check out the documentation from the start of this document if you get stuck! :) Ste