Ionic cordova platform add [android] giving errors

I am working on an ionic 3 project and I want to add android using the cordova platform add [android] --save command. But I am getting these errors

Using cordova-fetch for [android]
Error: Failed to fetch platform [android]
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: cmd: Command failed with exit code 4294963238 Error output:
npm ERR! addLocal Could not install C:\Users\clement\Desktop\Agcm Knust ionic 3 project\Agcm_Knust\node_modules\[android]
npm ERR! path C:\Users\clement\Desktop\Agcm Knust ionic 3 project\Agcm_Knust\node_modules\[android]
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\clement\Desktop\Agcm Knust ionic 3 project\Agcm_Knust\node_modules\[android]'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\clement\AppData\Roaming\npm-cache\_logs\2017-05-10T15_34_29_340Z-debug.log

How do I solve this problem?

You used cordova platform add android, right?

What exactly are you executing?
Can you execute ionic info and give us the output please?

yes I used cordova platform add android

Below is my ionic info

global packages:

    @ionic/cli-utils : 1.0.0
    Cordova CLI      : 7.0.0
    Ionic CLI        : 3.0.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.0.0
    @ionic/cli-plugin-ionic-angular : 1.0.0
    Ionic Framework                 : ionic-angular 3.1.1

System:

    Node       : v6.9.1
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed

That’s a weird-looking path with all the spaces and square brackets. Does the problem persist even with a more conventional path (i.e. no spaces and punctuation characters in it)?

Wait, are you typing the square brackets around android? Why?

1 Like

Oh hell, I totally read over that.

Did you enter cordova platform add [android] --save? If so, just switch to cordova platform add android --save and it should all work.

Ionic had updated their CLI so now use ionic cordova in place of ionic like wise you can add platform using ionic cordova platform add android

1 Like

I has the same problem
Someone has the solution

Your problem is probably with npm, something to do with permissions and files. This happens quite often and is almost impossible to successfully debug (at least here in the forum).

One solution: Uninstall your node, install nvm (or nvm-windows when you are using Windows), install a new node with this, then install ionic and cordova again and try your command again. The problem should be gone.

For me, I got this error because I copied/pasted “cordova platform add ios --save” and it took out one of the dashes. So try typing it all out and see if that makes a difference.