apk反编译的报错 Could not decode ars c file Unsupported major.minor version 51.0

从网上下载的apk反编译工具包,运行:apktool d xxx.apk时,报错如下:

Exception in thread "main" brut.androlib.AndrolibException: Could not decode ars
c file
        at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:56)
        at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibRes
ources.java:491)
        at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.jav
a:74)
        at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.jav
a:66)
        at brut.androlib.Androlib.getResTable(Androlib.java:50)
        at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:189)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:114)
        at brut.apktool.Main.cmdDecode(Main.java:146)
        at brut.apktool.Main.main(Main.java:77)
Caused by: java.io.IOException: Expected: 0x001c0001, got: 0x00000000
        at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:48)
        at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:44)
        at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:10
2)
        at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:83)
        at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
        ... 8 more

在网上找解决办法,都说是需要更新apktool.jar,于是找到最新版本apktool_2.0.0rc4.jar进行替换。然后再次运行apktool d xxx.apk,报错如下:

Exception in thread "main" java.lang.UnsupportedClassVersionError: brut/apktool/
Main : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: brut.apktool.Main. Program will exit.
再次搜索解决办法,说是Jdk版本与新版apktool不兼容所致,需要升级Jdk。

原文见链接:http://blog.zhanghang.org/index.php/2015/01/13/apktool%E5%8F%8D%E7%BC%96%E8%AF%91%E7%9A%84%E6%8A%A5%E9%94%99/

原话是:

apktool-1.5.3是支持jdk1.6的最后一个版本(1.x不知道还更新不) ,2.x 开始不兼容jdk1.6
升级本地jdk版本即可

我升级完Jdk之后,反编译就可以正常用了。至此,我本地的反编译配置是:

1.Jdk版本:1.8.0_40;

2.apktool.jar版本:apktool_2.0.0rc4.jar


你可能感兴趣的:(Android)