重建cordova项目会导致build.xml出错

时间:2014-10-19 23:56:01

标签: android cordova ant

我一直关注cordova guide设置hello world项目。在我进行更改并尝试再次运行cordova emulate之前,所有内容都会正常运行。我在这个例子中使用了android模拟器。

我试图从hello world项目中删除android平台并重建,但它没有什么区别。

在看到this question之后,我还尝试在hello world app中从平台android中删除了ant-build和ant-gen,但仍然遇到同样的错误。

我的操作系统是Windows 8。

我收到以下错误

BUILD FAILED
C:\android-sdk\tools\ant\build.xml:932: The following error occurred while execu
ting this line:
C:\android-sdk\tools\ant\build.xml:950: java.lang.ArrayIndexOutOfBoundsException
: 1
at com.android.ant.DependencyGraph.parseDependencyFile(DependencyGraph.j
ava:180)
    at com.android.ant.DependencyGraph.<init>(DependencyGraph.java:54)
    at com.android.ant.SingleDependencyTask.initDependencies(SingleDependenc
yTask.java:87)
    at com.android.ant.AaptExecTask.execute(AaptExecTask.java:509)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
a:396)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    at org.apache.tools.ant.Main.runBuild(Main.java:851)
    at org.apache.tools.ant.Main.startAnt(Main.java:235)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 4 seconds

C:\Apache24\htdocs\bapp\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:\Apache24\htdocs\b
app\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Apache24\htdocs\bapp\platforms\android\cordova\build.bat: Command fail
ed with exit code 8
at ChildProcess.whenDone (C:\Users\danny\AppData\Roaming\npm\node_modules\co
rdova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)

1 个答案:

答案 0 :(得分:2)

在尝试了其他帖子的不同建议后做了一些更新。我将我的jdk更新到版本8,然后我卸载了android 20,21的构建工具,让我使用android-19的构建工具。这解决了这个问题。