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

How to Decompile and Recompile Jar Files

  1. 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.
  2. 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.
  3. Open the .jar file using any archive software like 7zip, and extract the classes.dex file to the Apktool folder.
    classes-dex
  4. 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.
    baksmali-classes-dex
  5. 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.
    smali-classout
  6. 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.
  7. 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.

3 COMMENTS

  1. I’m getting the exact same errors. Has nobody else had this issue since the first comment?

  2. When I try to recompile I get the following “errors”. How do I go about correctly recompiling the classout folder with the modifications?

This site uses Akismet to reduce spam. Learn how your comment data is processed.