IONIC CORDOVA: Cordova platform add android --save Running command - failed!


#1

I started getting this error after updating from cordova v6.5.x to the latest.

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova platform add android --save
(exit code 1):

    Using cordova-fetch for cordova-android@^6.1.2
    Error: Failed to fetch platform cordova-android@^6.1.2
    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 1 Error output:
    '"C:\Program Files\nodejs\npm"' is not recognized as an internal or
    external command,
    operable program or batch file.

#2

npm uninstall cordova ionic
npm cache clean -f
sudo npm install -g cordova@6.5.0


#3

Thanks or the response, Downgrading cordova works but those this mean I can’t use latest cordova version on my system? Or are there some things I need to do, Thanks.


#4

cordova 7.0.1 has problem with android and plugin, it working fine with IOS, and I don’t know how to solve it too.


#5

Step 1: Post your ionic info output.


#6

Ionic Info

global packages:

    @ionic/cli-utils : 1.5.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.5.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.1.2
    Ionic Framework                 : ionic-angular 3.5.3

System:

    Node       : v7.5.0
    OS         : Windows 8
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 5.3.0

#7

Remove the android platform with ionic cordova platform remove android.
Then run ionic cordova platform list to see the available platforms.
You should see ~6.2.2 for Android.
Then run ionic cordova platform add android to add it, it will install the most current 6.2.3.


#8

When I do this with --verbose I get the error below

[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
> cordova platform remove android --save
× Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[DEBUG] !!! ERROR ENCOUNTERED !!!
[ERROR] An error occurred while running cordova platform remove android --save
        (exit code 1):

        Removing platform android from config.xml file...
        Error: cmd: Command failed with exit code 1 Error output:
        '"C:\Program Files\nodejs\npm"' is not recognized as an internal or
        external command,
        operable program or batch file.

When I check my platform folder, the android platform was actually removed.


#9

I would upgrade node to newest LTS or current - whatever suits you.
As you are on windows, use https://github.com/coreybutler/nvm-windows to do that - after a few minutes to install this once changing node is then a matter of seconds.


#10

thank you …
you save my day


#11

it’s work. save my time, thanks dude.


#12

Worked fine. :slight_smile:


#13

Thanks a lot it’s save my day


#14

npm install @ionic/cloud-angular@latest --save
sudo npm update -g cordova
sudo npm update -g ionic


#15

Thank YOU!!! Works perfectly


#16

If I have android ~7.1.1
what can i do?


#17

getting the error as well and i have android ~7.1.1 too


#18

DId you ever find an answer


#19

Were you able to resolve


#20

i didn’t find an answer