Ionic cordova run android FAILURE

Already done, same problem also with a new project!

So there is nowhere an output of the error from that promise? Maybe some hint in the console before the UnhandledPromiseRejectionWarning error?

You could try to upgrade npm with npm i -g npm, remove the npm_modules folder and run npm i in your project.

The only output is the same that I’ve report above:

ionic cordova platform add android
Using cordova-fetch for cordova-android@~7.0.0
(node:5988) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec
tion id: 1): Error: cmd: Command failed with exit code ENOENT
(node:5988) DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the Node.js p
rocess with a non-zero exit code.
[ERROR] No platforms detected. Please run: ionic cordova platform add

With the Upgrade of npm I had several problems some time ago, I had to downgrade to these versions (Node 7.9.0 and relative npm 4.2.0) in order to correctly create a new project and the whole tree of the node_modules folder (with newest versions
I could not able to create @ionic/app-scripts and some other folders in node_modules).

Try using cordova platform add android without ionic in front of it to test, if the error depends on the ionic cli.

By the way, I am using nvm on mac. It allows me to switch between different versions of node on the fly. There is something similar for windows (https://github.com/coreybutler/nvm-windows).

Also without “ionic” in front of “cordova” the error is the same.

I can try to Upgrade Nodejs and npm, no problem, in case it wasn’t the solution I will perform a new downgrade, with which versions of Nodejs and npm do you suggest to try?

I would recommend:
Node.JS 8.9.4 LTS

I have the following npm modules installed globally:

├── cordova@8.0.0
├── ionic@3.19.1
└── npm@5.6.0

Here we are, I’ve upgraded and now I’ve your same configurations.
I’ve start a new project without any problem, and then added the android platform.

ionic cordova platform add android

The output is this:

Using cordova-fetch for cordova-android@~7.0.0
(node:6176) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Failed to fetch platform cordova-android@~7.0.0
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 ENOENT
(node:6176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

ionic cordova resources android --force
V Collectin resource configuration and source images - done!

? Platform android not detected. Would you like to install it? <Y/n>

Try ionic cordova platform add android --nofetch --verbose

Same error :frowning:

But
CordovaError: Failed to fetch platform cordova-android@~7.0.0
gives us some more information about the error.

Try this:
set PATH=%PATH%;C:\Windows\System32
and then restart your cmd tool

No differences :confused:

Even with verbose and nofetch flag?
ionic cordova platform add android --nofetch --verbose

can you post the output from npm info once more?

And did you have to reinstall the global npm modules? If not, try to reinstall cordova:

npm uninstall -g cordova
npm cache clean
npm install -g cordova

ionic cordova platform add android --nofetch --verbose

Return this:

C:\Users\...\testnumbersix>ionic cordova platform add android --nofetch --verbose

[DEBUG] Reason for not using local CLI: LOCAL_CLI_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'C:\\Users\\f.menghini\\Desktop\\ionic\\testnumbersix', local:
        false, binPath:
        'C:\\Users\\f.menghini\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\
\ionic',
        libPath:
        'C:\\Users\\f.menghini\\AppData\\Roaming\\npm\\node_modules\\ionic\\dist
\\index.js'
        }
> cordova platform add android --save
Using cordova-fetch for cordova-android@~7.0.0

(node:5480) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec
tion id: 1): CordovaError: Failed to fetch platform cordova-android@~7.0.0
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 ENOENT
(node:5480) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
 Node.js process with a non-zero exit code.

> ionic cordova resources android --force
[DEBUG] resourceJsonStructure=3
[DEBUG] platforms=
V Collecting resource configuration and source images - done!

? Platform android not detected. Would you like to install it? (Y/n)

However, there are some important information, in my opinion, with

npm info

It says:

C:\Windows\system32>npm info
npm ERR! Invalid package.json

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\f.menghini\AppData\Roaming\npm-cache\_logs\2018-01-22T15_1
3_22_811Z-debug.log

Sorry i misspelled it. Should be ionic info.

Did you try the reinstall of cordova?

No problems :wink:
Yes, I’ve tried to remove/reinstall, now my ionic info is:

cli packages: (C:\Users\f.menghini\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.4
    npm               : 5.6.0
    OS                : Windows 7

Environment Variables:

    ANDROID_HOME : C:\Users\f.menghini\AppData\Local\Android\Sdk

Misc:

    backend : pro

You are not in an business environment where you need proxies, right?

Someone wrote, that it is a problem with cordova 8.
Try
npm uninstall -g cordova
npm install -g cordova@7.1.0

Yes, I’m in an business environment and I’m under proxy!

However I’ve tried the cordova downgrade and now I have:

Using cordova-fetch for cordova-android@~6.3.0
Error: Failed to fetch platform cordova-android@~6.3.0
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 ENOENT

[ERROR] Exception:

Yes the deprecation warning goes away, because it wasn’t flagged as deprecated in 7.1.0.
I got many problems with a proxy-environment, so I gave up and my system was moved to an own environment.
I think your system should work fine even with cordova 8.0.0.
The problem seems to be the proxy.
Try to follow this guide until the end:

I’ve tried to follow that guide but I don’t understand something:

It talk about environment variables, I’ve to add:
HTTP_PROXY=“http://proxy.example.com:8888” # also used by npm
HTTPS_PROXY=“https://proxy.example.com:8888” # also used by npm
IONIC_HTTP_PROXY="http://proxy.example.com:8888"
as they are written, using the server proxy.example.com?