decompiling DEX into Java sourcecode

后端 未结 17 1435
情歌与酒
情歌与酒 2020-11-22 12:41

How can one decompile Android DEX (VM bytecode) files into corresponding Java sourcecode?

17条回答
  •  感动是毒
    2020-11-22 13:21

    A more complete version of fred's answer:

    Manual way

    First you need a tool to extract all the (compiled) classes on the DEX to a JAR.
    There's one called dex2jar, which is made by a chinese student.

    Then, you can use jd-gui to decompile the classes on the JAR to source code.
    The resulting source should be quite readable, as dex2jar applies some optimizations.

    Automatic way

    You can use APKTool. It will automatically extract all the classes (.dex), resources (.asrc), then it will convert binary XML to human-readable XML, and it will also dissassemble the classes for you.
    Disassembly will always be more robust than decompiling, especially with
    JARs obfuscated with Pro Guard!

    Just tell APKTool to decode the APK into a directory, then modify what you want,
    and finally encode it back to an APK. That's all.

    Important: APKTool dissassembles. It doesn't decompile.
    The generated code won't be Java source.
    But you should be able to read it, and even edit it if you're familiar with jasmin.
    If you want Java source, please go over the Manual way.

提交回复
热议问题