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

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.
1 Like

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

9 Likes

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.

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.

1 Like

Step 1: Post your ionic info output.

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

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.

3 Likes

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.

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.

thank you …
you save my day

1 Like

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

Worked fine. :slight_smile:

Thanks a lot it’s save my day

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

Thank YOU!!! Works perfectly

If I have android ~7.1.1
what can i do?

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

DId you ever find an answer

Were you able to resolve

i didn’t find an answer