Android applications are packed inside a APK file, which is just a ZIP file containing among other things a compact Dalvik Executable (.dex) file.
First step is to extract the “classes.dex” file from the APK:
$ unzip program.apk classes.dex Archive: program.apk inflating: classes.dex
Now, we use the tool dex2jar to convert the classes.dex file to Java .class files:
$ bash dex2jar/dex2jar.sh ./classes.dex version:0.0.7.8-SNAPSHOT 2 [main] INFO pxb.android.dex2jar.v3.Main - dex2jar ./classes.dex -> ./classes.dex.dex2jar.jar Done.
From here we obtain the file “classes.dex.dex2jar.jar”, now we can use the java decompiler JD-GUI to extract the source code:
$ ./jd-gui classes.dex.dex2jar.jar
Now just go to “File -> Save all sources” and it will generate the zip file “classes.dex.dex2jar.src.zip” containing all the decompiled Java source code