Dawid Mostert
Dawid Mostert

Reputation: 123

Visual Studio Cordova build fails

When I build any android app with Cordova, it fails with

TypeError: Cannot read property 'prepEnv' of undefined.

I've done all the troubleshooting and checked environment variables (As per MS documentation)

What I found is that if I call bld\Debug\platforms\android\cordova\build --ant --debug from my project folder, the build works.

But when I call "C:\Users\<user>\AppData\Roaming\npm\\node_modules\vs-mda\vs-cli.cmd" build --platform Android --configuration Debug --projectDir . --rojectName Gappy --npmInstallDir C:\Users\<user>\AppData\Roaming\npm --language en-US --buildTarget AndroidDevice, the build fails.

One of the steps of the second method, is to call the first batch file.

This happens with VS2013 and VS2015. 64 and 32 bit versions of Node.JS

Any help / ideas?

Upvotes: 7

Views: 2754

Answers (2)

bhu1st
bhu1st

Reputation: 1318

On Mac OS X Yosemite:

Cleaning the project and rebuilding it with sudo fixed it for me.

On /path/to/your/project/platforms/android/cordova folder:

sudo ./clean
sudo ./build --release

Upvotes: 0

Florian Fogl
Florian Fogl

Reputation: 216

I noticed that the build file is called differnetly depending on whether the path to the solution contains spaces:

1> ------ Build configuration options: 1> Running command: C:\Projects\Mobile\AppSolutionName\AppSolutionName\bld\Debug\platforms\android\cordova\build.bat --debug --ant

1> ------ Build configuration options: --debug 1> Running command: cmd "/s /c ""C:\Projects\Mobile Apps\AppSolutionName\AppSolutionName\bld\Debug\platforms\android\cordova\build.bat" --debug --ant ""

It works if there are spaces and it fails with "TypeError: Cannot read property 'prepEnv' of undefined" if there are none. I don't know if this is specific to my environment but with the spaces in the path I can build now.

Upvotes: 15

Related Questions