dex2jar cannot read dex generated by smali 2.0.5 tool.
take a dex file that converts fine with dex2jar, give it a round trip through baksmali and smali, and dex2jar is no longer able to read the file. the new file works in dalvik VM though, and smali tool author says the dex file is within specs. apparently it is dex2jar's dex reader's fault.
this is discussed here:
https://code.google.com/p/smali/issues/detail?id=220
a comment in that ticket (reproduced below) by smali's author is worth noting...
Dec 31, 2014
[Project Member] #20 jesusfreke@jesusfreke.com
Yes, the problem is that dex2jar can't read the valid dex file that smali produces.
Here is a summary of the differences in how the annotations are represented in the dex file:
Per the dex specification ( http://source.android.com/devices/tech/dalvik/dex-format.html ), either encoding is acceptable, and both encodings are semantically identical. The fact that dex2jar can't read a valid dex file is a bug in dex2jar.
If the resulting dex file didn't work identically to the original on a device, then I would consider it a bug. I code to what dalvik/art expect and can handle, not some third party tool.
note: this affects dex-tools-2.1-20150221.123035-13.zip
hi,
the annotation reading bug in known on 0.0.9.x, and patched on 2013-11-21
'fix annotation read bug'
it should be released with 0.0.9.16, but the 2.x is out, and the 0.0.9.x branch is abandoned.
the 2.x branch works fine on the annotations,
i have tried the classes.dex/classesPreSmali.dex/classesFrom141.dex/classesFrom203.dex from https://code.google.com/p/smali/issues/detail?id=220, all works.
are you still using an old version of dex2jar ?
it is easy to identify 0.0.9.x and 2.x
1. for
at com.googlecode.dex2jar.v3.Dex2jar.to(Dex2jar.java:261)
, thev3
package is only available on 0.0.9.x and before. the new package name iscom.googlecode.d2j.dex
on 2.x2. the cmd line
dex2jar.sh
is removed on 2.x3. run cmd
d2j-dex2jar.sh
, the version is print on screenhi and thank you very much!
im sorry, i got confused. im using 2.1 snapshot myself. but this particular bug i encountered while using a tool that bundles its own copy of dex2jar. the tool is free software, but unfortunately the release is obfuscated (!!!), so i cant check the version of dex2jar. i assumed the bundled version is outdated and created a ticket in that project (https://github.com/Konloch/bytecode-viewer/issues/27). i will update this one with the results.
thank you again for your quick response.
hi!
as you guessed, that tool was bundling the 0.9.x branch. after the ticket the tool was updated to 2.0 and now it works fine. it is regrettable that the google code page is hosting an old snapshot and many people (like me for a while) think that 0.9.15 is the latest version.
i just finished a tool that modifies dex files (i need to document it and publish it asap) and i did it with dexlib2 from smali/baksmali. had i known that dex2jar had progressed, i would have taken a look at your lib before committing to dexlib2. i didnt find this new site in time.
anyway, go ahead and close this issue as invalid. thanks again for your help!!