离子 Android 构建失败
Ionic Android Build Failed
我刚开始进行混合开发,我选择了 cordova 和 ionic 作为起点。我正在关注离子文档。然而,在创建一个新的离子项目并添加 android 作为平台后,我在尝试构建 android 平台时多次失败。几天来我一直在努力解决这个问题。请提供帮助,以便我可以进行一些实际开发。
BUILD FAILED
C:\android-sdk-windows\tools\ant\build.xml:962: The following error occurred while executing this line:
C:\android-sdk-windows\tools\ant\build.xml:973: The following error occurred whi
le executing this line:
C:\android-sdk-windows\tools\ant\build.xml:312: com.android.sdklib.build.ApkCrea
tionException: java.io.FileNotFoundException: C:\todo\platforms\android\ant-buil
d\classes.dex does not exist
at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:469)
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(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.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 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)
Caused by: java.io.FileNotFoundException: C:\todo\platforms\android\ant-build\cl
asses.dex does not exist
at com.android.sdklib.build.ApkBuilder.checkInputFile(ApkBuilder.java:93
8)
at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:440)
... 62 more
Total time: 25 seconds
C:\todo\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:\todo\platforms\a
ndroid\build.xml -Dout.dir=ant-build -Dgen.absolute.dir=ant-gen"
ERROR building one of the platforms: Error: C:\todo\platforms\android\cordova\bu
ild.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: C:\todo\platforms\android\cordova\build.bat: Command failed with exit cod
e 8
at ChildProcess.whenDone (C:\Users\com\AppData\Roaming\npm\node_modules\cord
ova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
我终于能够通过进入 C:\todo\platforms\android\ant-build
文件夹来解决它,其中 todo
是我创建的离子项目的名称,并将 classes.dex.d
文件重命名为 classes.dex
很高兴你能弄明白!我发现执行 ionic android 和 ios builds 的最简单方法是通过 intel xdk。如果你已经有一个 ionic 项目,你可以将它作为一个 intel 项目导入,它在设备模拟器和 build 服务器中有一个 built。只需点击 build,它就会自动执行该过程。它还为您处理所有配置文件,并为您提供一个很好的 ui 来编辑它们。 https://software.intel.com/en-us/html5/tools
在一般的 cordova 中,我可能尝试删除平台并使用命令行重新添加它。
cordova platform rm android
cordova platform add android
但是,很高兴您找到了解决方法。
要解决此问题,请确保 Android SDK 安装成功,如果是
1) 从cordova项目目录返回(cd..)
2)然后进入cordova项目目录,使用"cordova platform add android --save --fetch"获取
3) 如果没有出现错误然后尝试删除平台并重新添加
对我有用
我刚开始进行混合开发,我选择了 cordova 和 ionic 作为起点。我正在关注离子文档。然而,在创建一个新的离子项目并添加 android 作为平台后,我在尝试构建 android 平台时多次失败。几天来我一直在努力解决这个问题。请提供帮助,以便我可以进行一些实际开发。
BUILD FAILED
C:\android-sdk-windows\tools\ant\build.xml:962: The following error occurred while executing this line:
C:\android-sdk-windows\tools\ant\build.xml:973: The following error occurred whi
le executing this line:
C:\android-sdk-windows\tools\ant\build.xml:312: com.android.sdklib.build.ApkCrea
tionException: java.io.FileNotFoundException: C:\todo\platforms\android\ant-buil
d\classes.dex does not exist
at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:469)
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(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.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 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)
Caused by: java.io.FileNotFoundException: C:\todo\platforms\android\ant-build\cl
asses.dex does not exist
at com.android.sdklib.build.ApkBuilder.checkInputFile(ApkBuilder.java:93
8)
at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:440)
... 62 more
Total time: 25 seconds
C:\todo\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:\todo\platforms\a
ndroid\build.xml -Dout.dir=ant-build -Dgen.absolute.dir=ant-gen"
ERROR building one of the platforms: Error: C:\todo\platforms\android\cordova\bu
ild.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: C:\todo\platforms\android\cordova\build.bat: Command failed with exit cod
e 8
at ChildProcess.whenDone (C:\Users\com\AppData\Roaming\npm\node_modules\cord
ova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
我终于能够通过进入 C:\todo\platforms\android\ant-build
文件夹来解决它,其中 todo
是我创建的离子项目的名称,并将 classes.dex.d
文件重命名为 classes.dex
很高兴你能弄明白!我发现执行 ionic android 和 ios builds 的最简单方法是通过 intel xdk。如果你已经有一个 ionic 项目,你可以将它作为一个 intel 项目导入,它在设备模拟器和 build 服务器中有一个 built。只需点击 build,它就会自动执行该过程。它还为您处理所有配置文件,并为您提供一个很好的 ui 来编辑它们。 https://software.intel.com/en-us/html5/tools
在一般的 cordova 中,我可能尝试删除平台并使用命令行重新添加它。
cordova platform rm android
cordova platform add android
但是,很高兴您找到了解决方法。
要解决此问题,请确保 Android SDK 安装成功,如果是
1) 从cordova项目目录返回(cd..) 2)然后进入cordova项目目录,使用"cordova platform add android --save --fetch"获取 3) 如果没有出现错误然后尝试删除平台并重新添加
对我有用