Cordova / Phonegap Android模拟器构建错误

时间:2014-06-04 14:49:22

标签: android cordova ant

我使用的是Cordova 3.4.0,

当我尝试跑步时:

cordova emulate android

我收到此错误:

BUILD FAILED
/Users/danny/Documents/Development/adt-bundle-mac/sdk/tools/ant/build.xml:932: The following error occurred while executing this line:
/Users/danny/Documents/Development/adt-bundle-mac/sdk/tools/ant/build.xml:950: java.lang.ArrayIndexOutOfBoundsException: 1
    at com.android.ant.DependencyGraph.parseDependencyFile(DependencyGraph.java:180)
    at com.android.ant.DependencyGraph.<init>(DependencyGraph.java:54)
    at com.android.ant.SingleDependencyTask.initDependencies(SingleDependencyTask.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(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java: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(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java: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(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java: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(DefaultExecutor.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: 2 seconds

/Users/danny/Documents/Apps/washbox/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: ant with args: debug,-f,/Users/danny/Documents/Apps/washbox/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/danny/Documents/Apps/washbox/platforms/android/cordova/run: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:126:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Process.ChildProcess._handle.onexit (child_process.js:820:5)

一切都在以前工作,但当我更改我的www文件夹时,我收到了这个错误。即使我恢复到虚拟文件phonegap / cordova给你我仍然得到同样的错误?

是否有人知道可能导致此问题的原因?谢谢

2 个答案:

答案 0 :(得分:6)

这里的答案帮助了我:Cordova won't build anymore

  

删除文件夹'ant-build'和'ant-gen'应解决你的问题   问题

所以,例如。

find . -name ant-build -o -name ant-gen | xargs rm -rf

答案 1 :(得分:2)

当我更改www目录中的文件时,我也遇到了这个错误。您应首先构建项目,然后运行:

cordova build android

然后运行:

cordova run android

我希望这会有所帮助。