无法在Visual Studio中构建Cordova项目

时间:2014-06-04 15:10:23

标签: android visual-studio visual-studio-cordova

我使用的是Visual Studio 2013和Cordova CTP 1.1。当我尝试构建项目时,我得到以下神秘错误(为了可读性而添加了换行符):

Error 22 
The command ""C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\vs-cli"
prepare --platform Android --configuration Debug
--projectDir . --projectName "servermon"" exited with code 8.
C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets 115 5 servermon

我已尝试过this question以及this question的解决方案,但这似乎并不能解决问题。我的系统路径似乎包含所有相关内容:

C:\Program Files\Java\jdk1.7.0_60\bin
C:\Users\Nathan\AppData\Local\Android\android-sdk\tools
C:\Users\Nathan\AppData\Local\Android\android-sdk\platform-tools
C:\apache-ant-1.9.3\bin
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\
C:\Program Files (x86)\Windows Live\Shared
C:\Program Files\Microsoft\Web Platform Installer\
C:\Program Files (x86)\nodejs\
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\ 

我还打开了SDK管理器,并确保获得最新的(Rev 19)构建工具。系统已经多次重启,我仍然无法构建。有没有人对如何解决这个构建问题有任何想法?

编辑:这是我的SDK Manager的屏幕截图 Android SDK Manager

Edit2:这是构建输出

1>------ Build started: Project: servermon, Configuration: Debug Android ------
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\Microsoft.TypeScript.targets(90,5): warning : The TypeScript Compiler was given no files for compilation, so it will skip compiling.
1>  Your environment has been set up for using Node.js 0.10.26 (ia32) and npm.
1>  ------ Ensuring correct global installation of package from source package directory: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\al3uox1v.u2n\packages\vs-mda
1>  ------ Build settings:
1>  ------    buildCommand: prepare
1>  ------    platform: Android
1>  ------    cordovaPlatform: android
1>  ------    configuration: Debug
1>  ------    cordovaConfiguration: Debug
1>  ------    projectName: servermon
1>  ------    projectSourceDir: C:\Users\Nathan\Documents\CordovaTest\cordovatest\cordovatest
1>  ------ App dir C:\Users\Nathan\Documents\CordovaTest\cordovatest\cordovatest\bld\Debug already exists
1>  ------ Copying app files to www
1>  ------ Done copying app files to www
1>  ------ Copying res files
1>  ------ Done copying res files
1>  ------ Platform android already exists
1>  ------ Certificate copy from C:\Users\Nathan\Documents\CordovaTest\cordovatest\cordovatest\res\cert\android to platforms\android
1>  ------ Done copying certificate files to platforms\android
1>  
1>  C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\q\q.js:126
1>                      throw e;
1>                            ^
1>  CordovaError: The provided path "C:\Users\Nathan\Documents\CordovaTest\cordovatest\cordovatest\bld\Debug\platforms\android" is not an Android project.
1>      at Object.android_parser (C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\src\metadata\android_parser.js:37:15)
1>      at C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\src\prepare.js:51:23
1>      at Array.map (native)
1>      at Object.prepare (C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\src\prepare.js:49:35)
1>      at preparePlatform (C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\app.js:322:24)
1>      at _fulfilled (C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\q\q.js:787:54)
1>      at self.promiseDispatch.done (C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\q\q.js:816:30)
1>      at Promise.promise.promiseDispatch (C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\q\q.js:749:13)
1>      at C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\q\q.js:557:44
1>      at flush (C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\node_modules\q\q.js:108:17)
1>C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets(115,5): error MSB3073: The command ""C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\vs-cli" prepare --platform Android --configuration Debug --projectDir . --projectName "servermon"" exited with code 8.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

3 个答案:

答案 0 :(得分:8)

似乎Cordova下载的Android模板已“损坏”。

解决这个问题: 尝试删除用户目录中缓存的android平台:

C:\users\<username>\.cordova\android\*

然后,在Visual Studio中清理并构建解决方案。或者确切地说,删除项目文件夹中的“bld”目录。

这应该迫使Cordova重新下载Android模板并解决问题。

答案 1 :(得分:2)

对我来说,我刚刚删除了bld文件夹,一切都变得正确了

答案 2 :(得分:1)

有些时候,visual studio catch会产生问题,请清除缓存。

  1. 选择Apache Cordova的工具,选项,工具,然后选择 科尔多瓦工具。

  2. 选择Clear Cordova Cache。

  3. 关闭并重新打开您的项目。

  4. 选择Build,Clean Solution。