Couldn't Download Cordova Plugin Error in Visu

2020-06-21 01:45发布

问题:

I am trying to install plugin for my cordova app in Visual Studio 2015 its giving error:

Couldn't download plugin.

If I tried to install it using CLI error is:

Current Directory is not cordova based project

回答1:

  1. run following command to install cordova globally

    npm install -g cordova

  2. Then create new cordova project using

    cordova start project_name

  3. Go to directory and Install plugin using

    cordova plugin add org.apache.cordova.file

  4. Copy Installed folder org.apache.cordova.file & paste into plugins folder in Visual Studio solution (Create plugins folder in root if not exist).

Update config file

<vs:plugin name="org.apache.cordova.file" version="1.3.1" />
  1. Build the Project

OR

Simply Add Following Lines in Config.xml.

<vs:features>
    <vs:feature>https://github.com/phonegap-build/PushPlugin.git</vs:feature>
</vs:features>

Build the project and observe bld/debug/plugins folder

One of two ways should work for you



回答2:

There currently is an issue with plugin history in the official Cordova plugin repository that is likely causing this error.

Use a git URI instead to get the latest plugin by entering it into the custom tab.

Ex: https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

You can find the git URIs here: http://plugins.cordova.io/#/package/org.apache.cordova.device

Update 2/16 12:55pm PT: Plugin history is in the process of being restored. VS pinned plugins are working as of this time. You should no longer need to use this workaround.



回答3:

Not quite sure what broke this exactly, but this workaround should do the trick:

At the command line:

> npm install -g cordova
> mkdir cordovaTemp
> cd cordovaTemp
> cordova create .
> cordova plugin add org.apache.cordova.device

Next, copy & paste the cordovaTemp/plugins sub-folders into your project's /plugins folder, and then do the following in Visual Studio:

  • Open the config.xml file
  • Navigate to Plugins > Custom
  • Select the Local radio button
  • Click the ... icon to browse for the new sub-folder under your project's plugins folder

Hope it helps.



回答4:

I was having this exact problem. Even by adding the git address in the config.xml manually wasn't working for me.

The problem is that I am behind a corporate proxy and even though my npm and visual studio are configured to that proxy, my git wasn't and this process uses the git clone function.

To solve I've just had to add my proxy configurations in my git:

git config --global http.proxy http://username:password@my.proxy.com:1234
git config --global https.proxy http://username:password@my.proxy.com:1234


回答5:

I had the same problem using Visual Studio 2013 Update 4 with Cordova Tools. I'm also behind a corporate proxy, after tried the solutions above I had to create the HTTP_PROXY and HTTPS_PROXY enviroment variable.

HTTP_PROXY = http://username:password@proxyhost:proxyport
HTTPS_PROXY = http://username:password@proxyhost:proxyport
Where your username:password is your login credentials.

My visual studio, npm and git proxy settings were also set up.