Cordova:构建android hello world app时的ant错误代码1

时间:2014-05-26 16:55:18

标签: android cordova ant ubuntu-12.04 java-7

在Ubuntu 12.04上干净安装Cordova,然后安装Android ADT捆绑包并将平台工具和工具添加到路径中。 然后在apache Cordova从toturial创建了hello app。但它拒绝建立。

查看我收到的错误:

aus@devhost:/opt/android_app/hello$ cordova build
Running command: /opt/android_app/hello/platforms/android/cordova/build
Buildfile: /opt/android_app/hello/platforms/android/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 22.6.2
 [checkenv] Installed at /opt/android_app/hello/adt-bundle-linux-x86_64-20140321/sdk

-setup:
     [echo] Project Name: HelloWorld
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.3
     [echo] Resolving Build Target for HelloWorld...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Resolving Dependencies for HelloWorld...
[dependency] Library dependencies:
[dependency]
[dependency] ------------------
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...

nodeps:

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 22.6.2
 [checkenv] Installed at /opt/android_app/hello/adt-bundle-linux-x86_64-20140321/sdk

-setup:
     [echo] Project Name: CordovaLib
  [gettype] Project Type: Android Library

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.3
     [echo] Resolving Build Target for CordovaLib...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /opt/android_app/hello/platforms/android/CordovaLib/ant-   build/rsObj
    [mkdir] Created dir: /opt/android_app/hello/platforms/android/CordovaLib/ant-build/rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for CordovaLib...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------

-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...

BUILD FAILED
/opt/android_app/hello/adt-bundle-linux-x86_64-20140321/sdk/tools/ant/build.xml:601: The following error occurred while executing this line:
/opt/android_app/hello/adt-bundle-linux-x86_64-20140321/sdk/tools/ant/build.xml:653: The following error occurred while executing this line:
/opt/android_app/hello/adt-bundle-linux-x86_64-20140321/sdk/tools/ant/build.xml:698:     Execute failed: java.io.IOException: Cannot run program "/opt/android_app/hello/adt-bundle-linux-x86_64-20140321/sdk/build-tools/android-4.4.2/aapt" (in directory "/opt/android_app/hello/platforms/android/CordovaLib"): error=2, No such file or directory
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
 at java.lang.Runtime.exec(Runtime.java:617)
 at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:41)
 at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428)
 at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442)
 at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:628)
 at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:669)
 at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:495)
 at com.android.ant.AaptExecTask.execute(AaptExecTask.java:699)
 at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
 at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 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:120)
 at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
 at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 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:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 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:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 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.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
 at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
 at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:440)
 at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:303)
 at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:221)
 at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
 at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 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:120)
 at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
 at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 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.io.IOException: error=2, No such file or directory
 at java.lang.UNIXProcess.forkAndExec(Native Method)
 at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
 at java.lang.ProcessImpl.start(ProcessImpl.java:130)
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
 ... 68 more

Total time: 1 second
Error code 1 for command: ant with args: debug,-    f,/opt/android_app/hello/platforms/android/build.xml,-Dout.dir=ant-build,-    Dgen.absolute.dir=ant-gen
Error: /opt/android_app/hello/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:131:23)
    at ChildProcess.EventEmitter.emit (events.js:110:17)
    at maybeClose (child_process.js:992:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1064:5)

我缺少什么想法?似乎不是依赖项,我在安装npm,cordova,jdk-7,android sdk,ant,nodejs等时没有出错。

此外,在错误消息中它引用了build.xml,该文件与内容一起存在。但当我直接尝试使用蚂蚁时,我得到了:

aus@devhost:/opt/android_app/hello$ ant /opt/android_app/hello/platforms/android/build.xml
Buildfile: build.xml does not exist!
Build failed

可能应该使用这样的蚂蚁,但我必须尝试。

所以解决方案是运行这些命令: sudo dpkg --add-architecture i386 sudo apt-get -qqy更新 sudo apt-get -qqy install libncurses5:i386 libstdc ++ 6:i386 zlib1g:i386

很明显,android sdk对32位架构有一定的依赖性。

1 个答案:

答案 0 :(得分:4)

检查/opt/android_app/hello/adt-bundle-linux-x86_64-20140321/sdk/build-tools/android-4.4.2/aapt是否存在。如果确实存在,请检查下面提供修复的链接。看起来aapt依赖于zlib,它仅在i386架构中可用,因此您需要添加该架构和lib本身。

How to make Android's aapt and adb work on 64-bit Ubuntu without ia32-libs (works for versions 12, 13 and 14)