apktool b smali_dir
smali_dir 为反编译出来的数据目录
执行后可能会报错
I: Building resources...
W: /root/Desktop/tmp/qimao_dir/qimao_v5.4/AndroidManifest.xml:1: error: No resource identifier found for attribute 'compileSdkVersion' in package 'android'
W:
W: /root/Desktop/tmp/qimao_dir/qimao_v5.4/AndroidManifest.xml:1: error: No resource identifier found for attribute 'compileSdkVersionCodename' in package 'android'
W:
W: /root/Desktop/tmp/qimao_dir/qimao_v5.4/AndroidManifest.xml:37: error: No resource identifier found for attribute 'appComponentFactory' in package 'android'
W:
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code =
1): [/tmp/brut_util_Jar_75145076448849533262091191559183387531.tmp, p, --forced-package-
id, 127, --min-sdk-version, 19, --target-sdk-version, 26, --version-code, 50400, --
version-name, 5.4, --no-version-vectors, -F, /tmp/APKTOOL5890277078150715820.tmp, -e,
/tmp/APKTOOL1664296946725275904.tmp, -0, arsc, -I,
/root/.local/share/apktool/framework/1.apk, -S,
/root/Desktop/tmp/qimao_dir/qimao_v5.4/res, -M,
/root/Desktop/tmp/qimao_dir/qimao_v5.4/AndroidManifest.xml]
虽然看起来像是Warning,但这就是重打包失败的原因
当前我用的apktool版本为2.7.0
解决办法:删除掉AndroidManifest.xml中那些报错的属性(这些属性好像是apktool反编译时自动加进去的,非原始代码)
删除后打包成功
# 创建一个别名叫coolapk 的coolapk.keystore
keytool -genkey -keystore coolapk.keystore -keyalg RSA -validity 10000 -alias coolapk
本地会生成一个文件coolapk.keystore
#jarsigner 随jdk安装
#coolapk 是第二部创建的alias的值,这个必须保持一致
jarsigner -verbose -keystore coolapk.keystore -signedjar xxx_v5.4_signed.apk xxx_v5.4.apk coolapk