Issue building Android

The command “ionic cordova build android” is failing me.
Here is the error I’m getting:

> cordova build android
Android Studio project detected
(node:19196) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Cannot find module '../cordova/platform_metadata'

(node:19196) [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.

Here is my ionic info:

Ionic:

   ionic (Ionic CLI)  : 4.1.1 (C:\Users\The Arctic AS\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.9

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0, ios 4.5.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview 1.1.1, (and 14 other plugins)

System:

   NodeJS : v8.2.1 (C:\Program Files\nodejs\node.exe)
   npm    : 5.3.0
   OS     : Windows 10

Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: How to update Cordova CLI, Platforms and Plugins · ionic.zone

Thanks for the quick reply.
Yeah I wanted to keep an old version so that I knew everything would work well together, but somehow I’ve messed it up. Will try updating.

Hi @Sujan12 ,
I’m actually not able to add Android again… as a plaform.
Getting this issue:

t(node:20668) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Cannot find module '../cordova/platform_metadata'
(node:20668) [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

Same as before.

Interesting.

Post the complete output of the command with --verbose added at the end.

PS ...> ionic cordova platform add android@7.1.1 --verbose
  ionic:cli-utils Terminal info: { tty: true, ci: false } +0ms
  ionic:cli-utils CLI global options: { _: [ 'cordova', 'platform', 'add', 'android@7.1.1' ], help: null, h: null, verbose: true, quie
t: null, interactive: true, color: true, confirm: null, json: null, project: null, '--': [] } +4ms
  ionic:cli-utils:lib:project Project type from config: Ionic Angular 3 (ionic-angular) +0ms
  ionic:cli-utils Project name: undefined +219ms
  ionic:cli Context: { binPath: 'C:\\...\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath: '...\\AppData\\Roaming\\npm\\node_modules\\ionic', execPath: 'D:\\..\\..', version: '4.1.1' } +0ms
  ionic:cli-utils:lib:integrations:cordova:config Using config.xml: D:\...\...\config.xml +0ms
> cordova platform add android@7.1.1 --verbose --save
No scripts found for hook "before_platform_add".
Using cordova-fetch for cordova-android@7.1.1
saving exact
Running command: cmd "/s /c ""...\nodejs\npm.cmd" install cordova-android@7.1.1 --production --save-exact""
Command finished with error code 0: cmd /s /c ""...\nodejs\npm.cmd" install cordova-android@7.1.1 --production --save-exa
ct"
Removing "cordova-" prefix from cordova-android
(node:22132) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Platform android already added.
(node:22132) [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.

I’ve removed the folder structures, don’t want to share it.

If it fails first, you have to remove it completely before trying again.

I had to downgrade my cordova to 7.1.0, and then it worked.