Install The Cordova Plugin through CLI & how to run on android device

Hi Guys,

In Apache Cordova, the role of the plugin is very important to build the Cordova for any platform like android, ios, blackberry, window7 or window8. For each platform, we need the plugin for the basic component of the native-like Accelerometer, Device, Compass, Notification, Networking, Camera etc.

In the older version of the phone-gap it already build in the jar file but Apache Cordova3.1 version it provide you have to create your own plugin if you need for native each.

A plugin is a bit of add-on code that provides an interface to native components. You can design your own plugin interface. For the app to communicate closely with various device-level features, you need to add plugins that provide access to core Cordova APIs. There are many plugin the Apache Cordova provide so the thing how to install all those plugins in out Cordova project with command line Interface(CLI).

First, you need to create the Cordova project in your any directory. but make sure Cordova cmd have to installed in your machine. For creating the Cordova project use this command.
cordova create CordovaDemo
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.


D:\>cd cordovaproject

D:\cordovaproject>cordova create CordovaDemo com.sunil.demo CordovaDemo
Creating a new cordova project with name "CordovaDemo" and id "com.sunil.demo" a
t location "D:\cordovaproject\CordovaDemo"


Now you done to create the project and in the next step you need to add the platform in your cordova project but make whatever platform you going to add in the Cordova project it SDK already should be installed in your machine.

D:\cordovaproject>cd CordovaDemo

D:\cordovaproject\CordovaDemo>cordova platform add android
Checking Android requirements...
Creating android project...
Preparing android project


You can see in your cprdovaDemo project inside there platforms folder inside one android project created.
Now you add the plugin what you need.
For  ex you need to add the plugin for device add this way

D:\cordovaproject\CordovaDemo>cordova plugin add org.apache.cordova.device
Fetching plugin from "org.apache.cordova.device"...
Starting installation of "org.apache.cordova.device" for android
Preparing android project
org.apache.cordova.device installed on android.


Similarly you can add all plugin as per your requirement. Here are list of the plugins

     cordova plugin add org.apache.cordova.device
     cordova plugin add
     cordova plugin add org.apache.cordova.battery-status
     cordova plugin add org.apache.cordova.device-motion
     cordova plugin add org.apache.cordova.device-orientation
     cordova plugin add org.apache.cordova.geolocation
     cordova plugin add
     cordova plugin add
     cordova plugin add
     cordova plugin add org.apache.cordova.file
     cordova plugin add org.apache.cordova.file-transfer
     cordova plugin add org.apache.cordova.dialogs
     cordova plugin add org.apache.cordova.vibration
     cordova plugin add org.apache.cordova.contacts
     cordova plugin add org.apache.cordova.globalization
     cordova plugin add org.apache.cordova.splashscreen
     cordova plugin add org.apache.cordova.inappbrowser
     cordova plugin add org.apache.cordova.console

Now you can run your android project, but before running the android project inside your CordovaDemo Project you should know these things.
1. If you are making any changes in the CordovaDemo Project then first you need to prepare the Cordova. use the commond

D:\cordovaproject\CordovaDemo>cordova prepare
Generating config.xml from defaults for platform "android"
Preparing android project


Then it made changed in your config.xml automatic as you added the plugin ealiear or any changes you made. Do not make any change in your android project which are exist inside your CordovaDemo project. You can only make change inside the www folder of your CordovaDemo project. And after made changed you need to make cordova prepare every time.

After prepare the cordova you can run the android project on device or emulator. For this you make sure you have made the path for platforms-tools and tools in your environment system. If you not configure this path and add this two path in system environment .
Now run the android project on device use command

D:\cordovaproject\CordovaDemo>cordova run android

 and run on emulator use this command

D:\cordovaproject\CordovaDemo>cordova emulate android

 See the Screen shot

 Cheers Guys!!


  1. Cominform is your partner for efficient, custom-tailored business software-solutions. The Cominform team develops on innovative platforms and in line with cutting-edge standards. Here are options for Web Desktop,Web-Desktop, SAML Cordova Plugin , SQL Cordova Plugin , SAML Phonegap Plugin and SQL Phonegap Plugin.


Post a Comment

Popular posts from this blog

Getting data from db and show in listview in Android Apache Cordova

Insert form data into db and validate login Phonegap

Get Current Location and load on GoogleMap