Customization is one of the traits of the Android OSย which differentiates it from the other popular mobile operating systems in the market. Android is an open source OS which allows users to modify and compile new features which will make the user experience much better. If you’re not a layman in the world of Android, you might have heard at least a tad about custom ROMs, kernels, mods which are aimed to improve the user experience and performance of the OS. However, if you’re determined enough, you can start your journey in the Android development with some simple yet advanced tutorials. We’ve already done a brief guide on how to compile and decompile APKs which can be accessed from below link:
Jar executable files are another important set of files that are packed in the Android system which are responsible to give functionality to the OS. In short, Jarย files are the Java executable files which comprise of the logic functionality of any app or module.ย But if you’ve decompiled an APK file, you’ll notice that there are noย jarย files in the package but still, they function flawlessly. The reason behind this is that Android uses a classes.dex (Dalvik Executable) file which runs on the Dalvik runtime (DEX files continue in Lollipop builds as well). So, to add, modify or remove functions in an Android system, you need to decompile the DEX files.
A Jar file also contains a DEX file which can be easily decompiled and recompiled after required modifications are performed. The decompiled DEX file results in a bunch of Smaliย files which are the assembler files for the Android runtime. In layman language, they contain the processed Java code which contains all the Java functions and classes in a fuzzy format which needs careful observation to fiddle with. In thisย tutorial,ย we will show you how to decompile and recompile Jar files easily and safely.
Warning
This guide involves tweaking the system files which might damage your Android system if not followed carefully.ย Be extra cautious while you follow this guide, otherwise, you might end up with a bricked device. You alone are responsible for any consequences that might occur during the process. Weย shall not be held responsible for any damage to your device.
Preparations
- Install compatible USB drivers on your computer.
- Download the Apktool & smali files zip โย APKtool smali.zip
How to Decompile Jar Files
- Download the Apktool zipย file and extract them to a folder on your PC. Avoid extracting them on Desktop, because the black spaces in the username might pop some errors during the decompiling and recompiling.
- Copy the Jar file you wish to decompile to the same directory where you have extracted the Apktool files. You can directly pull and push files from your Android device using our guide.
- Open the .jarย file using any archive software like 7zip, and extract the classes.dexย file to the Apktool folder.
- Now, to decompile the DEX file, you can simply drag the classes.dex file onto theย Quick-Baksmali.cmdย file in the Apktool folder. This script will automatically decompile the DEX file and creates a folder called Classoutย in the same directory which contains a bunch ofย smaliย files.
- Once you’ve edited the required smali files and save them, simply drag the entire classoutย folder onto theย Quick-Smali.cmdย file. This script will recompile all the smali files and gives you a compact DEX file with the nameย new-classes.dex.ย Rename it to classes.dexย file.
- Open the Jar file using the 7zip softwareย and delete the existing classes.dex file and replace it with the newly compiled classes.dex from the previous step.
- Push this modded Jar file to the proper location either by using the ADB Push commandย or using a root explorer and setting proper permissions.
That’s it, folks, the process is extremely simple and there is no chance of bricking the device. However, be careful while playing with the smali files as the modifications you make might brick your device.
Read Next: Decompile, Modify and Compile APK Files with APK Easy Tool
When I try to recompile I get the following “errors”. How do I go about correctly recompiling the classout folder with the modifications?
I’m getting the exact same errors. Has nobody else had this issue since the first comment?