apktool的使用

1,有什么用

apktool可以解开apk,得到smail代码和资源文件;反过来,也可以将smail代码和资源文件打包成为apk

2,环境配置

1,安装java并且设置java环境变量
2,下载apktool.jar

3,解开APK

G:\XXHD\lyq\apktool>java -jar apktool.jar d AdvDemo.apk -f

命令解释
1,apktool.jar文件和AdvDemo.apk文件都放在G:\XXHD\lyq\apktool文件夹下面;
2,java -jar apktool.jar就是调用apktool.jar来工作(它会自己找到main函数执行);
3, 参数d表示解压(比如-d AdvDemo.apk就表示要解压AdvDemo.apk;也可以解压XX.jar包)
4,默认解压到AdvDemo文件夹下面;
5,-f的意思是说如果文件夹存在(G:\XXHD\lyq\apktool\AdvDemo),那就会覆盖掉;

4,报错

1,Exception in thread “main” java.lang.NullPointerException怎么办

G:\XXHD\lyq\apktool>java -jar apktool.jar d G:\XXHD\lyq\apktool\AdvDemo.apk
I: Using Apktool 2.0.0-RC4 on AdvDemo.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Administrator\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=versionCode, value=0x00000001
I: Loading resource table from file: C:\Users\Administrator\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=versionName, value=0x00000014
I: Loading resource table from file: C:\Users\Administrator\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=versionCode, value=0x00000001
I: Loading resource table from file: C:\Users\Administrator\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=versionName, value=0x00000014
Exception in thread "main" java.lang.NullPointerException
        at java.io.Writer.write(Unknown Source)
        at brut.androlib.res.util.ExtMXSerializer.writeAttributeValue(ExtMXSerializer.java:38)
        at org.xmlpull.mxp1_serializer.MXSerializer.attribute(MXSerializer.java:673)
        at org.xmlpull.v1.wrapper.classic.XmlSerializerDelegate.attribute(XmlSerializerDelegate.java:106)
        at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.writeStartTag(StaticXmlSerializerWrapper.java:267)
        at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.event(StaticXmlSerializerWrapper.java:211)
        at brut.androlib.res.decoder.XmlPullStreamDecoder$1.event(XmlPullStreamDecoder.java:83)
        at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:141)
        at brut.androlib.res.decoder.XmlPullStreamDecoder.decodeManifest(XmlPullStreamDecoder.java:153)
        at brut.androlib.res.decoder.ResFileDecoder.decodeManifest(ResFileDecoder.java:134)
        at brut.androlib.res.AndrolibResources.decodeManifestWithResources(AndrolibResources.java:294)
        at brut.androlib.Androlib.decodeManifestWithResources(Androlib.java:138)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:102)
        at brut.apktool.Main.cmdDecode(Main.java:165)
        at brut.apktool.Main.main(Main.java:81)

看这句C:\Users\Administrator\apktool\framework\1.apk
删除C:\Users\Administrator\apktool\framework\1.apk文件

5,打包

java -jar apktool.jar b SDKlro -f test.apk

你可能感兴趣的:(Android)