linux(64位) 环境下 apktool运行问题
一直以来都是在windows环境下部署的apktool反向工程环境,最近公司需求,需要将此环境配置到服务器上(linux 64位)。反向解包的时候没有问题,重新压包的时候报出一下错误。几经波折,终于找到了原因,跟大家分享一下。
apktool b xxxxxx
I: Using Apktool 2.0.2
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [/tmp/brut_util_Jar_4724925685454536622.tmp, p, --forced-package-id, 127,………………过长省略……………………/AndroidManifest.xml]
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:465)
at brut.androlib.Androlib.buildResources(Androlib.java:403)
at brut.androlib.Androlib.build(Androlib.java:291)
at brut.androlib.Androlib.build(Androlib.java:261)
at brut.apktool.Main.cmdBuild(Main.java:225)
at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [/tmp/brut_util_Jar_4724925685454536622.tmp,……………过长省略……………/AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:425)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:451)
... 5 more
Caused by: brut.common.BrutException: could not exec command: [/tmp/brut_util_Jar_4724925685454536622.tmp,……………过长省略……………AndroidManifest.xml]
at brut.util.OS.exec(OS.java:93)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:419)
... 6 more
Caused by: java.io.IOException: Cannot run program "/tmp/brut_util_Jar_4724925685454536622.tmp": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:485)
at brut.util.OS.exec(OS.java:84)
... 7 more
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:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 10 more
根据官方文档提示:apktool安装文档
apktool在linux系统上运行需要提供32位的编译环境。所以就需要在64的linux上安装32位的glibc、zlib、libstdc++
执行:
yum update libstdc++
yum install libstdc++.i686 glibc.i686 zlib.i686
ok,问题解决,如果更换apktool.jar,需要前往 cd apktool/framework/ 删除掉:1.apk
重现运行