Saturday, August 17, 2013

Install Apache Cordova Using Command Line Interface

The below article get you through installing Apache Cordova using command line interface. We can develop mobile applications for different mobile platforms (iOS, Android, Blackbeery, Windows Phone, Palm WebOS, Bada, and Symbian) using HTML5, CSS3 & Javascript without worrying about writing native code for each platform. As Apache Cordova provides powerful Javascript APIs which are consistent across multiple device platforms and built on web standards, the app should be portable to other mobile platforms with minimal to no changes.
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.
  • Node.js
  • Apache Ant
  • Android ADT Bundle for windows

Setup Node.js

Download and install node.js from Nodejs Download and verify the installation by typing the following command in the command prompt.
Nodejs Version

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 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, 
Ant Home
 Set the %ANT_HOME%\bin; to the path as displayed below,
Ant Path

Verify the installation of Ant by typing the following command in the command prompt, 
Ant Version
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 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,
ADT Platform-tools Path
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,
Cordova Version

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 


  1. Very helpfull!

    If u cant run "npm -install" after using the windows installer, you have to set a new enviromental variable called NODE_HOME to the directory of nodejs. After that add the NODE_HOME to the path variable.

  2. Very energetic post, I loved that a lot. Will there be a part 2?

    Look at my web site :: binary options review site

  3. Thank you! Following your guide has saved me a lot of time. It so easy to follow. Looking fordward more articles like project examples or similar.

  4. Amazing article! Thank you very much!