Ever felt to change the look and feel of an app or did you accidentally delete your source code. See how to decompile apk to get the source code and how to customize any android app.
This guide is divided into two parts:-
- We will see how to decompile apk and extract the source code.
- Step by step how to make, look and feel changes to an Android app.
Disclaimer
This guide is purely for educational purpose. We encourage the users to go through the legality before using this guide on any real world application.
Use Case
- Recover accidentally deleted source code from the apk file
- Analysis of security vulnerability and threat detection
- Modding apps
- Add a new feature
- Customize the look and feel
- Support for non-supported android version
Limitation
- Cannot extract the exact same source code as originally written.
- Some part of the code might not be correctly retrieved.
- If the app uses a custom framework you will need the custom framework apk file.
- Most apps do not use custom frameworks.
Requirement
- Windows System
- Java Runtime Environment (JRE) 1.7
- Apktools
- Dex2jar
- JD GUI
- Luyten
- Zip Signer App
Concepts & Overview
- Apk file is a zip file.
- Zip file consists of XML and other android application resources.
- Apktools decodes the resource files and converts the android bytecode into assembly level samli files.
- Dex2jar converts the dex files into java bytecode file archived inside the jar file.
- JD GUI and Luyten decompiles java byte code to java source code file.
Software Downloads & Installations
Create Install Directory
- Create an installation directory with any name in a suitable location.
Download and Install Apktools
- Download the latest version of Apktools jar file from the website given above.
- Copy apktool_x.y.z.jar into the newly created directory
- Rename apktool_x.y.z.jar to apktool.jar
- Right click and click on “save link as” on apktool.bat link
- Copy apktool.bat file in the same directory
Download and Install Luyten
- Go to Luyten website and download the latest release of luyten-x.y.z.exe
- Copy luyten-x.y.z.exe file in the same directory
Download and Install JD-GUI
- Go to JD-GUI website download the latest version of jd-gui-windows-x.y.z.zip
- Extract jd-gui-windows-x.y.z.zip file in the same directory
Download and Install Dex2jar
- Go to Dex2jar website download the latest stable release of dex-tools-y.x.zip
- Extract dex-tools-y.x.zip file in the same directory
- Rename d2j-dex2jar.bat to d2j
Download and Install JRE 1.7
- Download and install JRE 1.7 from the above link.
- In command prompt type Java – version this should show 1.7.
- Might show a higher version if your system has a newer version should still be fine.
Install Zip Signer App
- Go to play store and install Zip Signer App on your phone.
Set the Path Environment Variable
- Open System Property
- In Windows 7
- Click on the start button.
- Right-click on Computer and select properties.
- In Windows 8 and 10
- Right-click on the start button.
- Select system properties.
- In Windows 7
- Select advanced system settings.
- Under the advanced tab, click on environment variables.
- In user variables, select the path and click on edit.
- Type semicolon (;) and then the path name of your installation directory.
- Then click on OK and then again OK and then again OK.
Test Installed Software
- Open a new command prompt
- Click on start
- Type in cmd
- Then select cmd.exe
- Type the command apktool –version
- Should print out 2.2
#1: Get Source Code form APK JAVA + XML
Download APK from Play Store
Get the apk file for which you want to extract the source code. If the app is available in the play store, then view our tutorial for downloading the apk file directly from play store.
Decode APK Using Apktool
The second step is to use apk tools to decode the apk and extract Dex files and the resource files.
- Open command prompt
- Type cd “type here the location of the apk file” and press enter
- If the location is on a different drive then type the drive letter and then press enter.
- For apk with custom framework, install it by typing the command apktool if xyz.apk and hit enter (Optional)
- Replace xyz.apk with the name of your framework apk
- To decode your app apk file type in apktool d –m app.apk and hit enter
- Replace app.apk with the name of your application apk
The m option stands for match. This is usually done when you require the exact same resource files, but this prevents rebuilding the apk once you have modified it.
After decoding finishes find the decoded application resources in the same directory in a subfolder named after the application name.
Convert Dex to Jar using dex2jar
- Open command prompt
- Type d2j app.apk and hit enter
- Replace app.apk with the name of your application apk
Find the converted jar file in the same folder
Decompile Jar to Java Source Code
We will be using two applications to convert the jar file into Java code. We will be doing this because the conversion of android Dex code to a Java Jar file is not perfect and certain information is lost. This might lead to improper Java code from the jar file.
Using two applications provides alternate code for a particular file which was not decoded properly. So if for a particular file the code generated by the first application is not correct. Then we can check the code generated by the second application.
Decompile Jar to Java Source Code using JD-GUI
- Go to the installation directory and open jd-gui.exe.
- Select open a file go to the directory the jar file is present.
- Select the jar file and click open.
- Click on the file and click on Save All Sources.
- Select the directory where you want to save.
Decompile Jar to Java Source Code using Luyten
- Go to the installation directory and click on lyuten.exe
- Click on file and then click on Open File
- Select the directory where the jar file is saved and select the jar file
- Click on File and then click on Save All
- Select the location for saving the Java code
#2: Modify Apps Using APK Tool
Decode Pokemon GO APK Using Apktool
We will decode the apk file without using the m option. Since we now require to rebuild the application after modifying the required files.
- Open command prompt.
- Type cd “type here the location of the PokemonGo apk file” and press enter.
- If the location is on a different drive then type the drive letter and then press enter.
- To decode your app apk file type in apktool d PokemonGo.apk and hit enter
- Make sure to delete any previously decoded application in that folder.
Modify Pokemon GO Splash Screen
- Open the decoded PokemonGo apk folder.
- Click on the assets directory.
- Go to bin, then go to data.
- Search for the splash.png file in this directory.
- Open it using any image editor.
- Modify it in any manner I will overlap a cute Pikachu image over it.
- Save this modified splash screen by overwriting it on the original image.
Rebuild Pokemon Go Apk Using APkTool
- Open command prompt
- Type cd “type here the location of the PokemonGo apk file” and press enter.
- If the location is on a different drive then type the drive letter and then press enter.
- Type apktool b PokemonGo
Transfer Apk Using EZ File Explorer
- Open the EZ File Explorer app.
- Open the menu by tapping on the three lines icon on the top left corner.
- Tap on Network then on Remote Manager.
- Turn On FTP Server by tapping it.
- Open the phone storage by opening the file explorer and type the address shown in the EZ File Explorer app.
- Go to the directory with PokemonGo Apk File.
- Open PokemonGo directory and open dist folder.
- Copy the apk file in the dist folder.
- Paste it the phone storage.
Sign Apk Using Zip Signer App
- Open the zip signer app, tap on Input
- Select the apk file that you just copied to your phone
- Tap on sign the file
Install and Test Modified App
- Open the phone directory where you saved the apk file using EZ File Explorer
- Tap on the pokemongo-signed.apk it will install as an update to the app
- Tap install
- Open the Pokemon Go app you should see the modified splash screen.
I hope this guide helped you. If yes, consider supporting us. If you are facing some problem following this guide share it below in the comment section. We will try our best to resolve it. You can help others by sharing this guide with your friends whom you think could benefit from it.
At howisolve.com we provide you the with latest updates on technology, tutorials, tips and tricks, troubleshooting guides and much more. Subscribe to our newsletters to get regular updates straight to your inbox. Thanks reading friends see you later bye.