Jan 31, 2013

How to deodex

Whats an odex file?
Android packages or apks contain certain .odex files, whose supposed function is to save space. These files are collections of parts of an application that are optimized before booting. These files are actually collections of parts of an application that are optimized before booting. Doing so speeds up the boot process, as it preloads part of an application. On the other hand, it also makes hacking those applications difficult because a part of the coding has already been extracted to another location before execution.

What are the benefits of deodexing?
The main benefit is to be able to modify any apk. This could be from editing and entire apk from scratch to apply themes or other patches.

What are the disadvantages?
In theory you shouldn't experience any big disadvantage. The main thing you could experience is that the phone will take a little more to boot on the first boot, as the dalvik cache gets populated. Once populated, the rest of the boots should take less time until you wipe your dalvik cache.

What do we need

  • Java (JRE)
  • Android SDK
  • smali/baksmali jars from GoogleCode
  • any zip program

How to deodex

  1. Get the framework and apps you want to deodex from your phone or update zip.
  2. Use baksmali to disassemble and deodex the app or framework.
    java -Xmx1024 -jar baksmali.jar -a <api_level>
    -d <framework_dir> -x <odex_file>
    You can check valid api_levels in wikipedia.
  3. Use smali to assemble them back in a single file (classes.dex).
    java -Xmx1024 -jar smali.jar out -o classes.dex
    
  4. Use the zip program to open the app or framework and add the result file of point 3.
Once we have the app or framework file deodexed, we can delete the old .odex files.