我在Windows 7 for Android上为Cordova设置工作环境时遇到问题。我使用NetBeans 8并遵循本指南:Link Here 新项目 - >科尔多瓦 - >你好世界模板。
每当我尝试构建Cordova项目(在NetBeans中)时,我都会收到以下消息:
BUILD FAILED
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml:90: Cannot find C:\Users\Administrator\SkyDrive\Skolegang\Dataingeniør\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml
Total time: 0 seconds
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\node_modules\q\q.js:126
throw e;
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\run.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Command finished with error code 8: C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\run.bat --emulator
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\nbproject\build.xml:272: exec returned: 1
BUILD FAILED (total time: 47 seconds)
我用谷歌搜索了几个小时但似乎无法找到解决方案。有些人得到了一些相同的错误(不完全,但相似),但解决方案对我不起作用。一个问题是关于Java 8和1.9.0以下的ant版本(我使用Node 0.10.26,java 1.7.0_25,cordova 3.5.0-0.2.4和ant 1.9.4)。我还尝试使用控制台(CMD)创建一个新项目,但是在构建时它会给出完全相同的错误。创建项目没有问题,也没有将Android作为平台添加,问题在于构建项目。我认为环境变量设置正确,因为java,node,ant和cordova命令在cmd / powershell中工作正常,而check_reqs.bat
表示环境很好。
这一行会产生错误:<import file="${sdk.dir}/tools/ant/build.xml" />
。这是消息的其余部分:Cannot find C:\Users\Administrator\SkyDrive\Skolegang\Dataingeniør\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml.
以下是我在命令窗口中获得的错误(不使用NetBeans):
PS C:\ Users \ Administrator \ Desktop \ test \ fakeApp&gt; cordova build android
Running command: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\cordova\build.bat
Buildfile: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\build.xml
BUILD FAILED
C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\build.xml:90: Cannot find C:\Users\Administrator\SkyDrive\
Skolegang\Dataingeni├©r\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Admini
strator\Desktop\test\fakeApp\platforms\android\build.xml
Total time: 0 seconds
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\Administrator\Desktop\test\fakeApp\platforms\androi
d\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\cordova\build.bat: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\s
rc\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
我想也许这是一个路径问题,因为我在路径中有一个特殊的字母是NetBeansProjects存储(并且它也很长),但是在C:\创建一个测试目录并创建项目使用命令窗口给出了同样的错误。我是科尔多瓦的新人,所以我确信这是一个简单的解决方案,提前谢谢。
答案 0 :(得分:1)
我解决了它,虽然我试图在OneDrive文件夹之外创建一个cordova项目,我没有想到SDK路径(也存储在OneDrive中)。通过将SDK文件移动到C :(路径可能不包含特殊字母'ø')并更改环境变量的路径(以及NetBeans中的SDK路径),它现在可以完美运行。