This article describes you, how to install Apache Cordova and the Android SDK on a Windows machine. This is a quite complex process, which may take some time, but I suggest you to have patience and keep the things going. 

 Installing the Cordova CLI 

The Cordova command-line tool is distributed as an npm package.

 To install the cordova command-line tool, follow these steps: 

1.Download and install Node.js. On installation you should be able to invoke node and npm command on your command line.

2.(Optional) Download and install a git client, if you don't already have one. Following installation, you should be able to invoke git on your command line. The CLI uses it to download assets when they are referenced using a url to a git repo.

3.Lastly, install the cordova framework using npm utility of Node.js. The cordova module will automatically be downloaded by the npm utility.


Also Read: Guide to install and Setup Node.js


On OS X and Linux:       

$ sudo npm install -g cordova

On OS X and Linux, prefixing the npm command with sudo may be necessary to install this development utility in otherwise restricted directories such as /usr/local/share. If you are using the optional nvm/nave tool or have write access to the install directory, you may be able to omit the sudo prefix.

On Windows:

    C:\>npm install -g cordova


The -g flag above tells npm to install cordova globally. Otherwise it will be installed in the node_modules subdirectory of the current working directory. 

After installation completion, you should be able to run cordova on the command line with no arguments and it should print help text.

Create the App

Go to the directory where you maintain your source code, and create a cordova project:

       $ cordova create hello com.example.hello HelloWorld
 

This creates the required directory structure for your cordova app. The cordova created script generates a skeletal web-based application whose home page is the project's www/index.html file, by default.

Add Platforms

All subsequent commands need to be run within the project's directory, or any subdirectories:

$ cd hello
 

 Add the platforms that you want to target your app. We will add the 'ios' and 'android' platform and ensure they get saved to config.xml:

$ cordova platform add ios --save

$ cordova platform add android --save 

To check your current set of platforms:

$ cordova platform ls


Running commands to add or remove platforms affects the contents of the project's platforms directory, where each specified platform appears as a subdirectory. 

Note: When using the CLI to build your application, you should not edit any files in the /platforms/ directory. The files in this directory are overwritten timely when preparing applications for building, or when plugins are re-installed.

Install pre-requisites for building

To build and run apps, you need to install SDKs for each platform you wish to target. On the contrary, if you are using browser for development you can use browser platform which does not require any platform SDKs

To check if you satisfy requirements for building the platform:

$ cordova requirements

Requirements check results for android: Java JDK: installed . Android SDK: installed Android target: installed android-19,android-21,android-22,android-23,Google Inc.:Google APIs:19,Google Inc.:Google APIs (x86 System Image):19,Google Inc.:Google APIs:23

Gradle: installed 
Requirements check results for ios:
Apple OS X: not installed
Cordova tooling for iOS requires Apple OS X
Error: Some of requirements check failed


  Modified On Mar-19-2018 01:01:21 AM

Leave Comment