Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic Android Build Failed

I am starting out in hybrid development and I chose cordova and ionic to start off. I am following the ionic documentation. However after creating a new ionic project and adding android as a platform, I repeatedly fail while trying to build the android platform. I've been trying to solve this problem for days now. Kindly help so that i can move forward with some actual development.

    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)
like image 549
Kaushal Kapoor Avatar asked May 01 '15 18:05

Kaushal Kapoor


3 Answers

I was finally able to solve it by going into C:\todo\platforms\android\ant-build folder where todo is the name of the ionic project i created and rename the classes.dex.d file to classes.dex

like image 63
Kaushal Kapoor Avatar answered Nov 16 '22 22:11

Kaushal Kapoor


In general cordova, i might had tried to remove the platform and re-add it using the command line.

cordova platform rm android

cordova platform add android

But, I'm glad you found a fix.

like image 43
Steve Kennedy Avatar answered Nov 16 '22 22:11

Steve Kennedy


Glad you were able to figure it out! The easiest way i have found to do ionic android and ios builds is through intel xdk. If you have a ionic project already you can import it as an intel project, it has a built in device emulator and build server. Just hit build and it automates the process. It also handles all of the config files for you and gives you a nice ui for editing them. https://software.intel.com/en-us/html5/tools

like image 34
Jess Patton Avatar answered Nov 16 '22 23:11

Jess Patton