This tutorial concentrates on installing Apache Cordova in Windows PC for developing application for Android devices. The only difference in developing applications for other platforms is to install other platform specific sdk’s and build your project specific to your relevant platform. Cordova provides command line options to build apps to specific mobile platform provided the platform specific sdk is installed in the developer machine.
Let’s get started quickly with installing Cordova and get hands on creating a hello world app soon :)
The following are the prerequisite tools for installing cordova. You need to ensure that these tools/packages are installed and configured in your classpath.
- Apache Ant
- Android ADT Bundle for windows
Download and install node.js from Nodejs Download and verify the installation by typing the following command in the command prompt.
Setup Apache Ant
Before downloading Ant make sure that JDK is already installed in your computer. If not download the JDK (JDK Download) and install it before setting Ant.
Download apache-ant-x.x.x-bin.zip from Ant Download and extract the contents to a directory (Eg., E:\Tools\Project\Build\apache-ant-x.x.x). This directory will be known as ANT_HOME.
Open environment variables (Control Panel » System » Advanced » Environment Variables) add a new system variable as displayed below,
Set the %ANT_HOME%\bin; to the path as displayed below,
Verify the installation of Ant by typing the following command in the command prompt,
If you get any other messages related to java, then you need to check if JAVA_HOME is available in the environment variables. Else make sure to add the JDK installation path to the system variable and add %JAVA_HOME%\bin; to the path variable.
It is important to note that whenever the environment variables are modified, a new command prompt should be opened to verify the installation.
Setup Android ADT Bundle for Windows
As this article speaks about installing cordova for developing the apps for the android platform, it is important to download the Android Developer Tools and make sure that it is available in the system classpath.
If you are developing apps for other platforms, make sure that the developer tools or sdk for the platform is available in your classpath.
Extract the downloaded adt-bundle-windows-xxx_xx-xxxxxxxx.zip to a directory (E:\Tools\Project\android\adt-bundle-windows-x86_64-20130729).
This directory will contain the sdk for android. Add tools and platform-tools to the path variable of the environment variables as displayed below,
Once the environment is setup, an Android Virtual Device (AVD) should be added. The Virtual device is the target device on which the application created using cordova will be tested. The best resource for creating an AVD is Managing AVD
Hurrah All Set
All the required dependencies for setting up cordova has been already installed. Now lets get started with installing cordova using nodejs.
Open the command prompt and type the command,
npm install -g cordova
This command will download the latest version of all the node modules required by cordova.
Verify the installation of Cordova by typing the following command in the command prompt,
And this brings the end of Installing Cordova using Command Line Interface. I will soon come up with an article on Creating my first android app using Cordova.
And here it is. Create your first application using cordova by following this link Create Cordo Project