google / smali

Other
213 stars 35 forks source link

Smali fails to assemble classes.dex decompiled with baksmali #47

Closed hldr4 closed 6 months ago

hldr4 commented 6 months ago

Using smali 3.0.5-137d16c1-dirty

After successfully building the fatJars, I use baksmali to decompile like so java -jar baksmali.jar d -a 34 app_og/classes.dex -o classes

Then immediately try assembling it back with smali: java -jar smali.jar a -a 34 classes -o app/classes.dex.

And get the following error:

Exception in thread "main" java.lang.IndexOutOfBoundsException: toIndex = 128
        at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:507)
        at java.base/java.util.AbstractList.subList(AbstractList.java:497)
        at com.android.tools.smali.dexlib2.writer.DebugInfoCache.hashCode(DebugInfoCache.java:26)
        at java.base/java.util.HashMap.hash(HashMap.java:340)
        at java.base/java.util.HashMap.getOrDefault(HashMap.java:1053)
        at com.android.tools.smali.dexlib2.writer.DexWriter.writeDebugItem(DexWriter.java:1204)
        at com.android.tools.smali.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:1094)
        at com.android.tools.smali.dexlib2.writer.DexWriter.writeTo(DexWriter.java:409)
        at com.android.tools.smali.dexlib2.writer.DexWriter.writeTo(DexWriter.java:371)
        at com.android.tools.smali.smali.Smali.assemble(Smali.java:136)
        at com.android.tools.smali.smali.AssembleCommand.run(AssembleCommand.java:95)
        at com.android.tools.smali.smali.Main.main(Main.java:99)

This produces a crippled classes.dex about half the size of the original.

Happens irrespectively of wheteher any of the smali files have been modified. Also specifying the API version when decompiling or not doesn't change the result. Not specifying it or using a lower one during assembly appears to start the process, but produces a ton of other errors about such and such only supporting higher API levels.