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.
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.
- Install compatible drivers on your computer: Download here
- Download the Apktool & smali files zip → APKtool smali.zip
How to Decompile and Recompile 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 the files from your device using this 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.