In this short tutorial, I will show you how to extract the code source of an android application. Starting with the name of the application we will be able to generate the Java source code in 4 steps.
This tutorial assumes that the used operating system is based on Linux, in my case Ubuntu 16.04 but should work on most Unix-based systems.
Disclaimer: the following article is provided for learning and entertainment purpose only, with no guarantee that it will work and does not give the rights to apply the mentioned techniques on third-party applications.
Step-1: Download the APK File
The first step is to download the application apk file. For this, we can use tools that we find online. One of them is https://apkcombo.com/fr-fr/apk-downloader/ . Otherwise feel free to ask Google: “download apk”.
Step-2: Decompress the APK File
To decompress the APK just rename with a “zip” extension and then decompress it.
$ mv application.apk application.zip
$ unzip application.zip
Step-3: Extract Class Files
Among the extracted files, you will find a “classes.dex” file. This the file that contains the binary code in class file. To decompress it, use the “dextojar” command available at: https://github.com/pxb1988/dex2jar
$ d2j-dex2jar.sh classes.dex
This will generate a jar file containing the class file.
Step-4: Decompile Class Files
To decompile the class files we can use the jd-cli java decompiler available at https://github.com/kwart/jd-cmd
$ java -jar path-to/jd-cli.jar application.jar
$ jar xvf application.src.jar
Here you go! You should now have access to the java source code…
Feel free to comment, ask questions, and/or clap.
To compile dex2jar use the following steps:
$ cd dex-tools/build/distributions
$ unzip dex-tools-2.1-SNAPSHOT.zip
Then use the d2j-jar2dex.sh found in the unzipped folder.