关于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,命令如下:
java -jar apktool.jar d -s -f test.apk test
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进行对齐和签名即可
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值