Cordova创建脚本/ Ant无法执行aapt

时间:2013-05-31 03:39:39

标签: android cordova

我正在尝试为Andoid应用程序开发设置Cordova。我正在遵循本指南:http://cordova.apache.org/docs/en/2.7.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android。我正在运行最新的Linux Mint 15。

到目前为止,我已经安装了Android Developer Tools软件包,运行Java版本1.7.0的OpenJDK和安装了Ant 1.8.2。我已经将/ tools和/ platform-tools添加到我的$ PATH环境变量中。当然,我也将Cordova Android SDK解压缩并准备好了。随包管理器安装了Ant和Java; ADT软件包/ Android SDK和Cordova解压缩到我的主目录中。

我尝试按照入门指南运行以下命令,但脚本在Ant构建操作上失败。我对Java和Android堆栈的经验很少,并且无法确定如何继续使用。

./create ../../workspace/project com.nelson.wells myfirstapp

BUILD FAILED
/home/nelson/Development/adt-bundle-linux/sdk/tools/ant/build.xml:650: The following error occurred while executing this line:
/home/nelson/Development/adt-bundle-linux/sdk/tools/ant/build.xml:691: Execute failed: java.io.IOException: Cannot run program "/home/nelson/Development/adt-bundle-linux/sdk/build-tools/android-4.2.2/aapt": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
    at java.lang.Runtime.exec(Runtime.java:615)
    at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:862)
    at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481)
    at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495)
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:631)
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:672)
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:498)
    at com.android.ant.AaptExecTask.execute(AaptExecTask.java:699)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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:398)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    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:1023)
    ... 46 more

Total time: 1 second
An unexpected error occurred: ant jar > /dev/null exited with 1
Deleting project...

我知道该文件存在且我的用户有权执行它。

file /home/nelson/Development/adt-bundle-linux/sdk/build-tools/android-4.2.2/aapt
/home/nelson/Development/adt-bundle-linux/sdk/build-tools/android-4.2.2/aapt: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped
nelson@nelson-VirtualBox ~/Development/cordova-2.7.0/bin $ ls -la /home/nelson/Development/adt-bundle-linux/sdk/build-tools/android-4.2.2/aapt
-rwxrwx--- 1 nelson nelson 1122758 May 13 12:31 /home/nelson/Development/adt-bundle-linux/sdk/build-tools/android-4.2.2/aapt
nelson@nelson-VirtualBox ~/Development/cordova-2.7.0/bin $ 

有关正在发生的事情的任何想法?

2 个答案:

答案 0 :(得分:10)

如果您使用的是Ubuntu,我建议您查看一下:http://blog.mx17.net/2012/10/25/android-on-ubuntu-ioexception-on-aapt/。您可能需要安装32位库。根据您的Ubuntu版本,这可能意味着:

sudo apt-get install ia32-libs

或者类似的东西:

sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386

有关详情,请参阅https://askubuntu.com/questions/107230/what-happened-to-the-ia32-libs-package

答案 1 :(得分:2)

对于Fedora用户

yum install libstdc++.i686 zlib.i686