ThexXTURBOXx / dex2jar

Tools to work with android .dex and java .class files
Apache License 2.0
234 stars 59 forks source link

Issue with dex2jar: Index -1 out of bounds for length 0 #38

Open mbv opened 1 year ago

mbv commented 1 year ago
dex2jar ../app.apk -> ./app-dex2jar.jar
ASM fail to generate .class file: iko/lxf
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
    at org.objectweb.asm.Frame.getConcreteOutputType(Frame.java:1140)
    at org.objectweb.asm.Frame.merge(Frame.java:1185)
    at org.objectweb.asm.CurrentFrame.execute(CurrentFrame.java:53)
    at org.objectweb.asm.MethodWriter.visitVarInsn(MethodWriter.java:927)
    at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2409)
    at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1514)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:744)
    at org.objectweb.asm.ClassWriter.replaceAsmInstructions(ClassWriter.java:777)
    at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:740)
    at com.googlecode.d2j.dex.Dex2jar$1$1.visitEnd(Dex2jar.java:71)
    at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:555)
    at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:449)
    at com.googlecode.d2j.dex.Dex2Asm.convertDex(Dex2Asm.java:614)
    at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:153)
    at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:253)
    at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:103)
    at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:297)
    at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:16)
ASM fail to generate .class file: iko/oxf
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
    at org.objectweb.asm.Frame.getConcreteOutputType(Frame.java:1140)
    at org.objectweb.asm.Frame.merge(Frame.java:1185)
    at org.objectweb.asm.CurrentFrame.execute(CurrentFrame.java:53)
    at org.objectweb.asm.MethodWriter.visitVarInsn(MethodWriter.java:927)
    at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2409)
    at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1514)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:744)
    at org.objectweb.asm.ClassWriter.replaceAsmInstructions(ClassWriter.java:777)
    at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:740)
    at com.googlecode.d2j.dex.Dex2jar$1$1.visitEnd(Dex2jar.java:71)
    at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:555)
    at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:449)
    at com.googlecode.d2j.dex.Dex2Asm.convertDex(Dex2Asm.java:614)
    at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:153)
    at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:253)
    at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:103)
    at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:297)
    at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:16)
Detail Error Information in File ./app-error.zip

app-error.zip

will send apk to email

ThexXTURBOXx commented 1 year ago

Thank you very much, I have also received your email with the APK. I will take a look at it soon

Rabbit0w0 commented 1 month ago

This issue is basically caused by problems calculating frames. We can simply changes the flags passed to ClassWriter. We convert the dex to jar files not for running on Hotspot JVM (for sure), so frames aren't of necessity. Disabling the COMPUTE_FRAMES flag is ok to fix this. I think the dex2jar has an existing config system. You just need to disable the corresponding flag.