Skip to content Skip to sidebar Skip to footer

Cmd: Command Failed With Exit Code 2

I have recently installed Visual Studio 2015. I just created new project Installed>JavaScript>Blank App(Apache Cordova). I have selected Android>Google-Android-Emulator pl

Solution 1:

I have exactly the same issue ! I thought that space character might be a problem in the path but no change. My logs :

1> Running command: cmd "/s /c "c:\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\build.bat --debug --buildConfig=c:\BlankCordovaApp1\BlankCordovaApp1\build.json"" 1> Command finished with error code 2: cmd /s /c "c:\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\build.bat --debug --buildConfig=c:\BlankCordovaApp1\BlankCordovaApp1\build.json" 1>ERROR building one of the platforms : error : cmd: Command failed with exit code 2 1> You may not have the required environment or OS to build this project 1>MDAVSCLI : error : cmd: Command failed with exit code 2

What is weird is that when I launch manually on a cmd window

c:\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\build.bat --debug --buildConfig=c:\BlankCordovaApp1\BlankCordovaApp1\build.json

, it works well and my apk is created in the debug directory, so I'd say that maybe the problem comes from "/s /c . It just seems that the command simply cannot be executed, but I'm stuck here...

EDIT & Solution : I now have more informations. It seems it's due to a lack of heap memory : Go to Tools --> Options --> Projects and Solutions --> Build and Run, change MSBuild project build output verbosity to Diagnostic. Rebuild the project and post the text from output window. I have

Error occurred during initialization of VM (TaskId:11) 1> Could not reserve enough space for object heap (TaskId:11)

Check if you do not have the same. If yes, problem is simply resolved by installing a 64bit version of java (to know if yours is 64b, simply try java -d64 -version). In fact, this problem has already been resolved here : Visual Studio 2015 RC & Cordova: Could not reserve enough space for object heap (solved)

All you have to do is : -Install a 64b version of Java if you haven't. - Override the java home path in VS/Tools/Options/Tools for Apache Cordova / Environnement variable Overrides / JAVA HOME. For example, it's is now C:\Program Files\Java\jre1.8.0_51 for me. (carefull not to point to Program Files (x86) )

It works for me.

To go further, you might want have a look at this page explaining how to configure your real android device for debug : http://developer.xamarin.com/guides/android/getting_started/installation/set_up_device_for_development/

You might have to install proper usb drive for your phone, google generic one does not work for everyone. That's it !

Solution 2:

Setting up PATHs for cordova doesn't work with Environment variables. In Visual Studio (2013 or higher) you have to go to Tools > Options > Tools for Apache Cordova, and setup android sdk path from there. I've dealt with this error and found out that there's a Dependency Checker that tells you about all the things you need to run your code.

Post a Comment for "Cmd: Command Failed With Exit Code 2"