使用cordova构建android平台时出现异常

时间:2014-08-06 12:01:47

标签: cordova

使用cordova构建android有一个主要问题。

每次尝试

cordova build android 

我得到了这个例外:

BUILD FAILED
/Applications/android-sdk/sdk/tools/ant/build.xml:962: The following error occurred while executing this line:
/Applications/android-sdk/sdk/tools/ant/build.xml:973: The following error occurred while executing this line:
/Applications/android-sdk/sdk/tools/ant/build.xml:313: com.android.sdklib.build.ApkCreationException: Failed to add /Users/jensfischer/workspaceCordova/theorietrainer-app/platforms/android/ant-build/WinDriveTheorieTrainerWebApp.ap_
    at com.android.sdklib.build.ApkBuilder.addZipFile(ApkBuilder.java:547)
    at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:453)
    at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:394)
    at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:334)
    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.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 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)
Caused by: java.util.zip.ZipException: oversubscribed dynamic bit lengths tree
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:154)
    at java.io.FilterInputStream.read(FilterInputStream.java:90)
    at com.android.sdklib.internal.build.SignedJarBuilder.writeEntry(SignedJarBuilder.java:310)
    at com.android.sdklib.internal.build.SignedJarBuilder.writeZip(SignedJarBuilder.java:243)
    at com.android.sdklib.build.ApkBuilder.addZipFile(ApkBuilder.java:540)
    ... 63 more

Total time: 10 seconds
Error code 1 for command: ant with args: debug,-f,/Users/jensfischer/workspaceCordova/theorietrainer-app/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/jensfischer/workspaceCordova/theorietrainer-app/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135: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)

我花了一些时间搞清楚......但没有任何成功。阅读zip文件似乎有问题...

Android SDK工具22.6.2 科尔多瓦3.5.0-0.2.6

1 个答案:

答案 0 :(得分:2)

在我的情况下,这是由一条太长的路径引起的。

我的项目中有一个node_modules子文件夹,其中包含一个长依赖关系层次结构。我只需要这些依赖项来就地开发外部库。删除依赖项后,我能够再次编译。