JesusFreke / smali

smali/baksmali
6.29k stars 1.07k forks source link

Bad dex magic on api 25 #515

Open ftc opened 7 years ago

ftc commented 7 years ago

If this is the wrong place to post this feel free to close the issue. I am not really sure if this is an issue in soot or dexlib2 but any help would be greatly appreciated.

I am attempting to fix an issue I found in https://github.com/sable/soot where it will write out an APK with bad magic. I have also documented the issue on the soot github page here: https://github.com/Sable/soot/issues/731

The place where soot uses dexlib is in the following file: https://github.com/Sable/soot/blob/develop/src/soot/toDex/DexPrinter.java

I have found that if I read an APK (with a target api version 25) in and immediately write it back out of soot then the resulting dex file cannot be opened. However if I initialize the DexBuilder class (line 160) with api version 23 then it seems to make a working APK out of it even if I input a version 25 apk. Doing this seems like a bad workaround though.

I think this may be related to some comments in this issue: https://github.com/JesusFreke/smali/issues/500 however I am not 100% sure.

JesusFreke commented 7 years ago

Hmm. What is the error when the dex file cannot be opened?