Android APK unpack and analyze the Source Code

I needed to view the cource code to get some controls of the app.
Therefore, I summarized what I did for it.

How to get the Source Code(Extract & Analyze)
  1. Rename the APK files extension *.apk -> *.zip
  2. unzip the file.zip from 1.
  3. Find the file “classes.dex” in the unzipped folder. Then, convert it to *.java file using the command below in windows command prompt.
    d2j-dex2jar.bat classes.dex
  4. “classes-dex2jar.jar” file will be created.
  5. Launch “jd-gui.exe” and drag the file from 4. to the “Java Decompiler” window
  6. The classes including source codes will be shown. Export the files from “File -> Save all sources”

Tools


 

  • dex2jar
    download link:https://downloads.sourceforge.net/project/dex2jar/dex2jar-2.0.zip
  • JD-GUI
    1. Go to official web site(http://jd.benow.ca/)
    2. Switch the tag below “JD-GUI”, from “Overview” to “Download”


    3. Download links by OS will be shown. Click the one for Windows OS.


    4. Unzip the zip file and click  “jd-gui.exe” to launch.
    5. To get the extracted source codes, drag the files you want to analyze, such as *.jar files into the window.

If you have any issue, please feel free to leave a comment!

References