user1619275
user1619275

Reputation: 365

Cordova 3.0.0 - How to install a plugin

I'm totally new to app development and just started to make my first steps. I've installed Cordova and the needed utilities according this guide.

I've created my first app (using Cordova's create script) and I'm able to run it on my Nexus 4. Now I tried to install a plugin using plugman, and I'm stuck. This tutorial says I can install a plugin using

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

in the application directory. Two issues here: 1. In the application directory itself isn't a executable file named "cordova" 2. When I swtich to the cordova directory and execute the mentioned command, I get this error:

Cordova does not recognize the command plugin

Any ideas what I'm doing wrong? Or is ther a mistake in the tutorial? Thanks a lot for any help!

EDIT: I managed to install the plugins using plugman directly using

plugman install --platform android --project . --plugin https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

But nevertheless I'm still interested in how to install the plugins using cordova...

Upvotes: 15

Views: 56615

Answers (3)

ashish.n
ashish.n

Reputation: 1224

I did it in this manner

D:\phonegap\hello>plugman install --platform android --project D:\phonegap\hello
\platforms\android --plugin org.apache.cordova.battery-status

where as for doing it from git

    plugman install --platform android --project D:\phonegap\hello
\platforms\android --plugin https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

Upvotes: 0

aqingsao
aqingsao

Reputation: 2104

Below are several ways I've used to install plugins from Cordova CLI, hope it helps:

Firstly, make sure you've installed cordova correctly(please refer to official document if needed):

cordova -v   // should print something like "3.5.0-0.2.6"
  1. Install from Cordova plugin registry

    cordova plugin add org.apache.cordova.device

    This should cover most cases and here is a list of plugins available in Cordova Plugin Registry.

  2. Install from a remote repository, typically from GitHub
    cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin

    If you encountered something like "Error: Command failed: error: Failed connect to help.github.com:443; Connection refused while accessing", typically it's a proxy issue, you could retry after config your proxy:

    git config --global http.proxy http://user:password@proxy:xxx

    If it still not works, you could click "Dowload Zip" from github, unzip the downloaded file and then:

  3. Install from a local directory

    cordova plugin add /path/to/directory

    It will look in this directory and each of its subdirectories for the plugin.

Upvotes: 24

Shailendra2014
Shailendra2014

Reputation: 819

NOTE: this is related to Android platform of cordova 3.4 on my windows 8 machine (tested)

step 1=> Install plugman by command in cmd "npm install -g plugman" (note that you must have node installed)

step 2=> Download git from http://msysgit.github.com/ for windows (15 mb) install exe file

step 3=> create new variable in enviorment variable name = GIT_PATH and value= "C:\Program Files (x86)\Git (this is mine urs may be diff)", now append %GIT_PATH% in Path variable (very Important) check git command in cmd if no error than continue otherwise fix this now

step 4=> Now go to http://plugins.cordova.io/#/ find whatever plugin want to install. and get just this repository url like

step 5=> now whatever and anywhere project is, place following command in cmd

**plugman install --platform android --project F:\my17app\ --plugin https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git**

Step 7=> If it successfully install we can see in app/res/xml/config.xml file a new feature will be added with id of new plugin

PS: For environment variables see in control Panel=> System and Security => System =>Advanced System Security 

Upvotes: 4

Related Questions