A-A+

Exception in thread “main” org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexFile: Not a valid dex magic value: cf

2020年05月29日 00:06 汪洋大海 暂无评论 阅读 93 views 次

关于apktool反编译出错Error occured at code address 0的解决办法

在使用apktool反编译apkeditor_v180的时候,出现了下面的错误:

I: Baksmaling...
Exception in thread "main" org.jf.dexlib.Util.ExceptionWithContext: Index: 4112,
Size: 1437
at org.jf.dexlib.Util.ExceptionWithContext.withContext(ExceptionWithCont
ext.java:54)
at org.jf.dexlib.IndexedSection.getItemByIndex(IndexedSection.java:77)
at org.jf.dexlib.Code.InstructionWithReference.lookupReferencedItem(Inst
ructionWithReference.java:79)
at org.jf.dexlib.Code.InstructionWithReference.<init>(InstructionWithRef
erence.java:57)
at org.jf.dexlib.Code.Format.Instruction22c.<init>(Instruction22c.java:5
9)
at org.jf.dexlib.Code.Format.Instruction22c.<init>(Instruction22c.java:4
0)
at org.jf.dexlib.Code.Format.Instruction22c$Factory.makeInstruction(Inst
ruction22c.java:103)
at org.jf.dexlib.Code.InstructionIterator.IterateInstructions(Instructio
nIterator.java:82)
at org.jf.dexlib.CodeItem.readItem(CodeItem.java:154)
at org.jf.dexlib.Item.readFrom(Item.java:77)
at org.jf.dexlib.OffsettedSection.readItems(OffsettedSection.java:48)
at org.jf.dexlib.Section.readFrom(Section.java:143)
at org.jf.dexlib.DexFile.<init>(DexFile.java:431)
at org.jf.dexlib.DexFile.<init>(DexFile.java:267)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:49)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:34)
at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:74)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:89)
at brut.apktool.Main.cmdDecode(Main.java:146)
at brut.apktool.Main.main(Main.java:77)
Caused by: java.lang.IndexOutOfBoundsException: Index: 4112, Size: 1437
at java.util.ArrayList.RangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at org.jf.dexlib.IndexedSection.getItemByIndex(IndexedSection.java:75)
... 18 more
Error occured while retrieving the field_id_item item at index 4112
Error occured at code address 0
code_item @0x5061c

原因,很明显是程序在字符串上面动了手脚。那么怎么样才能够正常的进行反编译呢?
解决办法:
1 使用apktool进行反编译,但是不要反编译source code,命令如下, -r 不反编译资源:
java -jar apktool.jar d -s -f -r test.apk
2 使用baksmali对classes.dex文件进行反编译,命令如下:
java -jar baksmali-2.0.2.jar -o test-out\ test\classes.dex
这样的话,所有的反编译后的smali文件都在test-out目录下了
3 使用smali对修改后的smali文件进行编译,从而编译出新的classes.dex,然后,替换旧的classes.dex文件,命令如下:
java -Xmx512M -jar smali-2.0.2.jar test-out\ -o test\classes.dex
4 使用apktool进行编译和打包
java -jar apktool.jar b -f test new-test.apk
5 最后使用zipalign和testsign.jar进行对齐和签名即可

Baksmali:https://github.com/JesusFreke/smali

Apktool:https://ibotpeaches.github.io/Apktool/

dex2jar:https://sourceforge.net/projects/dex2jar/

文章来源:https://www.it610.com/article/4906900.htm

布施恩德可便相知重

微信扫一扫打赏

支付宝扫一扫打赏

×

给我留言