Is there a way to get the source code from an APK file?

前端 未结 27 2306
难免孤独
难免孤独 2020-11-21 06:56

The hard drive on my laptop just crashed and I lost all the source code for an app that I have been working on for the past two months. All I have is the APK file that is st

27条回答
  •  春和景丽
    2020-11-21 07:49

    This is an alternative description - just in case someone got stuck with the description above. Follow the steps:

    1. download apktool.bat (or apktool for Linux) and apktool_.jar from http://ibotpeaches.github.io/Apktool/install/
    2. rename the jar file from above to apktool.jar and put both files in the same folder

    3. open a dos box (cmd.exe) and change into that folder; verify that a Java Environment is installed (for Linux check the notes regarding required libraries as well)
    4. Start: apktool decode [apk file]

      Intermediate result: resource files, AndroidManifest.xml

    5. unzip APK file with an unpacker of your choice

      Intermediate result: classes.dex

    6. download and extract dex2jar-0.0.9.15.zip from http://code.google.com/p/dex2jar/downloads/detail?name=dex2jar-0.0.9.15.zip&can=2&q=
    7. drag and drop classes.dex onto dex2jar.bat (or enter \dex2jar.bat classes.dex in a DOS box; for Linux use dex2jar.sh)

      Intermediate result: classes_dex2jar.jar

    8. unpack classes_dex2jar.jar (might be optional depending on used decompiler)
    9. decompile your class files (e.g. with JD-GUI or DJ Decompiler)

      Result: source code

    Note: it is not allowed to decompile third party packages; this guide is intended to recover personal source code from an APK file only; finally, the resulting code will most likely be obfuscated

提交回复
热议问题