Execute failed: java.io.IOException: Cannot run program "sdk-linux/build-tools/22.0.0/aapt": error=2

在Linux上使用ant编译打包apk的时候,出现下面的错误及解决方法:

1、/usr/local/android-sdk-linux/tools/ant/build.xml:698: Execute failed: java.io.IOException: Cannot run program "/usr/local/android-sdk-linux/build-tools/22.0.0/aapt": error=2, No such file or directory


BUILD FAILED
/svcroot/workspace/build/MobileAppAndorid/build.xml:94: The following error occurred while executing this line:
/usr/local/android-sdk-linux/tools/ant/build.xml:653: The following error occurred while executing this line:
/usr/local/android-sdk-linux/tools/ant/build.xml:698: Execute failed: java.io.IOException: Cannot run program "/usr/local/android-sdk-linux/build-tools/22.0.0/aapt": 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:58)
	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:441)
	at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
	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)
	... 59 more

原因:在64位Linux下打包成APK时缺少x86下C++语言库。

解决: 
# yum install -y compat-libstdc++-296.i686 
# yum install -y compat-libstdc++-33.i686



2、/usr/local/android-sdk-linux/build-tools/20.0.0/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory


-code-gen:
[mergemanifest] Found modified input file
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] /usr/local/android-sdk-linux/build-tools/20.0.0/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

BUILD FAILED
/svcroot/workspace/build-app/MobileAppAndorid/build.xml:94: The following error occurred while executing this line:
/usr/local/android-sdk-linux/tools/ant/build.xml:653: The following error occurred while executing this line:
/usr/local/android-sdk-linux/tools/ant/build.xml:698: null returned: 127

解决: # yum install -y zlib

(yum配置可以参考帖子 http://blog.csdn.net/catoop/article/details/41345471 我用的是RHEL 6.5版本的Linux)


3、[aapt] /android/sdk/build-tools/android-4.4/aapt: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory 

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] /android/sdk/build-tools/android-4.4/aapt: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory 

原因:在64位Linux下打包成APK时缺少x86下C++语言库。

解决: 
# yum install -y libstdc++.so.6


如果2、3的问题还没有解决,使用下面的命令试试:


# yum install glibc*.i686
# yum install zlib*.i686
# yum install libstdc++.so.6



如果在执行 yum install libstdc++.so.6 的时候出现如下错误:

Error:  Multilib version problems found. This often means that the root
       cause is something else and multilib version checking is just
       pointing out that there is a problem. Eg.:

         1. You have an upgrade for libstdc++ which is missing some
            dependency that another package requires. Yum is trying to
            solve this by installing an older version of libstdc++ of the
            different architecture. If you exclude the bad architecture
            yum will tell you what the root cause is (which package
            requires what). You can try redoing the upgrade with
            --exclude libstdc++.otherarch ... this should give you an error
            message showing the root cause of the problem.

         2. You have multiple architectures of libstdc++ installed, but
            yum can only see an upgrade for one of those arcitectures.
            If you don't want/need both architectures anymore then you
            can remove the one with the missing update and everything
            will work.

         3. You have duplicate versions of libstdc++ installed already.
            You can use "yum check" to get yum show these errors.

       ...you can also use --setopt=protected_multilib=false to remove
       this checking, however this is almost never the correct thing to
       do as something else is very likely to go wrong (often causing
       much more problems).

       Protected multilib versions: libstdc++-4.4.7-11.el6.i686 != libstdc++-4.4.7-4.el6.x86_64

解决办法:yum update libstdc++-4.4.7-4.el6.x86_64


然后再执行:yum install libstdc++.so.6 

---------------

(完)

时间: 2015-07-30

Execute failed: java.io.IOException: Cannot run program &quot;sdk-linux/build-tools/22.0.0/aapt&quot;: error=2的相关文章

exception i java.io.ioexception:Error opening jar:

问题描述 exception i java.io.ioexception:Error opening jar: exception in thread main java.io.ioexception:Error opening jar 解决方案 根据错误提示,打开一个jar文件错误. 解决方案二: 异常:org.htmlparser.util.ParserException: Error in opening a connection to java.io.IOException: Inv..

jsp标签-在JSP中抛出java.io.IOException: tmpFile.renameTo(classFile) failed异常怎么解决

问题描述 在JSP中抛出java.io.IOException: tmpFile.renameTo(classFile) failed异常怎么解决 在JSP中抛出java.io.IOException: tmpFile.renameTo(classFile) failed异常怎么解决 解决方案 你确定不是控制台抛出而是JSP抛出! 解决方案二: java.io.IOException: tmpFile.renameTo(classFile) failedjava.io.IOException:

java.io.IOException: Call to Hadoop.Master/IP:port failed on local e

问题描述 java.io.IOException:CalltoHadoop.Master/192.168.10.196:9111failedonlocalexception:java.io.EOFExceptionatorg.apache.hadoop.ipc.Client.wrapException(Client.java:1144)atorg.apache.hadoop.ipc.Client.call(Client.java:1112)atorg.apache.hadoop.ipc.RPC$

启动web harvest的时候出现Caused by: java.io.IOException: Could not get shel

问题描述 当使用java -jar命令的时候,出现如下异常,请各位看看,我还是新手:d:worktec_crawlers>java -jar webharvest.jarException in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError at org.webharvest.gui.Ide.<init>(Unknown Source) at CommandLine$1.run(Unkn

struts1整合mybatis【java.io.IOException: Could not find resource configuration.xml】

问题描述 java.io.IOException: Could not find resource configuration.xmlat org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:89)at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:76)at org.apache.ibatis.io.Resources.getRe

java.io.IOException: CreateProcess error=3, ???????有高手知道怎么解决吗

问题描述 java.io.IOException:Cannotrunprogram"/usr/bin/nsupdate":CreateProcesserror=3,???????atjava.lang.ProcessBuilder.start(ProcessBuilder.java:459)atjava.lang.Runtime.exec(Runtime.java:593)atjava.lang.Runtime.exec(Runtime.java:431)atjava.lang.Run

java.io.IOException: Timed out waiting 20000ms for a quorum of nodes to respond

16-11-14 21:23:41,540 FATAL org.apache.hadoop.hdfs.server.namenode.FSEditLog: Error: starting log segment 4234 failed for required journal (JournalAndStream(mgr=QJM to [192.168.58.183:8485, 192.168.58.181:8485, 192.168.58.182:8485], stream=null))java

java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.

1:这个问题都被大家玩烂了,这里我也记载一下,方便以后脑补: 1 SLF4J: Class path contains multiple SLF4J bindings. 2 SLF4J: Found binding in [jar:file:/E:/360Downloads/hadoop-2.4.1/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 3 SLF4J:

在eclipse的console栏中一直显示java.io.IOException

在eclipse的console栏中一直显示java.io.IOException: 您的主机中的软件中止了一个已建立错误.具体如下. [2013-09-02 17:24:14 - ddmlib] 您的主机中的软件中止了一个已建立的连接. java.io.IOException: 您的主机中的软件中止了一个已建立的连接. at sun.nio.ch.SocketDispatcher.write0(Native Method) at sun.nio.ch.SocketDispatcher.writ