首先下载准备
//下载地址
[这里写链接内容](https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.3.0.jar)
[这里写链接内容](https://connortumbleson.com/apktool/googlecode/apktool-install-windows-r05-ibot.tar.bz2)
//说明
将下载到的文件全部放到一起,并将apktool_2.3.0.jar版本号去掉,如下:
aapt.exe
apktool.bat
apktool.jar
//添加path环境变量或者将要反编译的apk放到apktool目录里
反编译命令:apktool d app-release.apk -o outdir
输出信息:
I: Using Apktool 2.3.0 on app-release.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\admin\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
回编译命令:apktool b outdir
输出信息:
I: Using Apktool 2.3.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
W: D:\Users\admin\Desktop\Workspace\outdir\AndroidManifest.xml:3: error: No resource identifier found for attribute 'roundIcon' in package 'android'
W:
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\admin\AppData\Local\Temp\brut_util_Jar_263114362956284402.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 26, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, C:\Users\admin\AppData\Local\Temp\APKTOOL427190514248737921.tmp, -0, arsc, -0, arsc, -I, C:\Users\admin\AppData\Local\apktool\framework\1.apk, -S, D:\Users\admin\Desktop\Workspace\outdir\res, -M, D:\Users\admin\Desktop\Workspace\outdir\AndroidManifest.xml]
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:485)
at brut.androlib.Androlib.buildResources(Androlib.java:419)
at brut.androlib.Androlib.build(Androlib.java:318)
at brut.androlib.Androlib.build(Androlib.java:270)
at brut.apktool.Main.cmdBuild(Main.java:224)
at brut.apktool.Main.main(Main.java:75)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\admin\AppData\Local\Temp\brut_util_Jar_263114362956284402.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 26, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, C:\Users\admin\AppData\Local\Temp\APKTOOL427190514248737921.tmp, -0, arsc, -0, arsc, -I, C:\Users\admin\AppData\Local\apktool\framework\1.apk, -S, D:\Users\admin\Desktop\Workspace\outdir\res, -M, D:\Users\admin\Desktop\Workspace\outdir\AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:454)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:471)
... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\admin\AppData\Local\Temp\brut_util_Jar_263114362956284402.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 26, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, C:\Users\admin\AppData\Local\Temp\APKTOOL427190514248737921.tmp, -0, arsc, -0, arsc, -I, C:\Users\admin\AppData\Local\apktool\framework\1.apk, -S, D:\Users\admin\Desktop\Workspace\outdir\res, -M, D:\Users\admin\Desktop\Workspace\outdir\AndroidManifest.xml]
at brut.util.OS.exec(OS.java:95)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:448)
... 6 more
出现错误,最后总结出解决方法,加 -r 参数,忽略资源文件
//删除outdir目录
新反编译命令:apktool d -r app-release.apk -o outdir
输出信息:
I: Using Apktool 2.3.0 on app-release.apk
I: Copying raw resources...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
新汇编命令:apktool b outdir
输出信息:
I: Using Apktool 2.3.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
[Fatal Error] :1:1: 前言中不允许有内容。
I: Checking whether resources has changed...
I: Copying raw resources...
I: Building apk file...
I: Copying unknown files/dir...
成功!
生成的apk默认放在outdir/dist目录中