Error in adding android platform in ionic

I m getting the following error while adding android platform to my project.

PS C:\Users\nitin94\Desktop\YugmaV2> ionic cordova platform add android
× cordova platform add android --save - failed!
[ERROR] Exception: Adding android project…

    Creating Cordova project for the Android platform:
            Path: platforms\android
            Package: io.ionic.starter
            Name: MyApp
            Activity: MainActivity
            Android target: android-25
    Subproject Path: CordovaLib
    Android project created with cordova-android@6.1.2
    Installing "cordova-plugin-camera" for android
    Failed to install 'cordova-plugin-camera':Error: cmd: Command failed with exit code ENOENT
         at ChildProcess.whenDone
         at emitOne (events.js:96:13)
         at ChildProcess.emit (events.js:188:7)
         at Process.ChildProcess._handle.onexit (internal/child_process.js:213:12)
         at onErrorNT (internal/child_process.js:367:16)
         at _combinedTickCallback (internal/process/next_tick.js:80:11)
         at process._tickCallback (internal/process/next_tick.js:104:9)
    Error: cmd: Command failed with exit code ENOENT

I had already added the cordova plugins using the cmds
ionic cordova plugin add cordova-plugin-camera

and similar cmds for all the other plugins.

Though platform addition has failed, it has created a platform/android folder in my project with many other files and folder inside it.
My ionic info is:

PS C:\Users\nitin94\Desktop\YugmaV2> ionic info

cli packages: (C:\Users\nitin94\Desktop\YugmaV2\node_modules)

@ionic/cli-utils  : 1.9.1
ionic (Ionic CLI) : 3.9.1

global packages:

Cordova CLI : 6.5.0

local packages:

@ionic/app-scripts : 2.0.2
Cordova Platforms  : android broken
Ionic Framework    : ionic-angular 3.5.3


Node : v6.11.2
npm  : 3.10.10
OS   : Windows 10

As u can see , android broken is mentioned in the added platform . I dont understand what does broken mean? I guess it is because of that error.
i have not installed Android SDK/ studio prior adding the plaform, do i need to do that?
Please help if u have any idea.

How do you want to add android platform without the android SDK?

I dont know much about the process.
i thought that sdk is required to build the apk file by using the result of ‘platform add command’.
Can u elaborate the steps required to build the apk for ionic project and how to resolve my current error.
Thanks in advance.

You are correct, the SDK is not required to install the android platform.

Your problem is probably with npm, something to do with permissions and files. This happens quite often and is alsmot impossible to successfully debug.

One solution: Uninstall your node, install nvm-windows, install a new node with this, then install ionic and cordova again and try again. The problem should not occur again.


After installing the nvm-windows. which node version i should install as i m already using the latest stable version. And could u tell me why i need nvm-windows , because as far as i know, it is used to manage multiple node version in single machine, but i m using only one latest node version.

You install whatever version you want.

nvm-windows (and nvm) has the advantage of moving the node installations to a location where the OS doesn’t mess with files and permissions as much as with the normal node (and thus npm) installations. It is also a new installation, that is not messed up yet as your current one may be (running anything as Administrator or using sudo tends to do that).