Visual Studio Cordova build fails

泄露秘密 提交于 2019-12-10 03:54:07

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/29029116/visual-studio-cordova-build-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!