[Epic 4G Android Development] zman0900:
Flashable Zip to ODEX CyanogenMod 7.2​

I've heard that an ODEXed rom can be faster that a deODEXed rom, or at least the apps will load faster. This may or may not be true, but ODEX does provide one noticeable advantage that the system apps and frameworks no longer require storage space on /data in the dalvik-cache. It uses more space on /system, but there is plenty to spare there with CyanogenMod.

One of the main reasons roms are usually deodexed is to allow themers and the like to easily edit apks and frameworks. Since cyanogen has the Theme Chooser app that doesn't need to modify files, I decided to try odexing. This is loosely based off of a script by Decad3nce for the Hero.

So far I haven't noticed anything broken by this, and it seems a bit faster. I have no way to tell if its actually faster, but there's no harm in trying it for yourself.

Advantages:

More free space on /data

Possibly faster app loading time and phone bootup.

Disadvantages:

More space used on /system (so what?)

Moding system apk files and framework not easy. (ex. Theme flashable zips won't work, but CM has its own theme app that still works.)

Instructions:

NANDROID!!!

Flash zip (be patient, it takes a while)

Reboot

How to flash a new nightly: IMPORTANT!

Flash cm_epicmtd_full-##.zip

Flash gapps-gp-20110828-signed.zip

Flash auto-odex-cm7_2.zip

Notes on using custom kernels:

Custom frameworks: If the kernel (or anything else) flashes any .jar file in /system/framework/ you MUST flash it before odexing. If you want to flash after odexing, open the kernel zip on your computer and delete the jar file from /system/framework/.

Zipalign: Kernel's that zipalignshould be flashed after this. My odex script deletes the classes.dex file from every app/framework it odexes which modifys the zips. I haven't verified this, but I am assuming that negates the effects of the zipalign.

If the kernel both zipaligns and has custom frameworks, you must make a choice of which feature you find more useful. If you want zipalign more, delete the custom frameworks and flash after odexing. If you want the custom frameworks more, flash before odexing.

How to undo (deodex):

Do NOT just delete the .odex file from /system/app or /system/framework !!!!!

You have two options here:

Advanced restore nandroid of /system

--OR-- Reflash CyanogenMod and Google Apps.

Download:

auto-odex-cm7_2.zip - 948 KB

This has been tested to work on CyanogenMod 7.2 Nightly 12 and 13.

It should work on any other nightly or the RC0, but no guarantees...

How it works:

The flashable zip runs a script that runs a program called dexopt-wrapper on every framework file in BOOTCLASSPATH order, then every system apk included with CM and gapps. It then deletes the classes.dex file from all of those frameworks and apks. Last it clears the dalvik cache since much of it will now be unneeded.

The dexopt-wrapper binary doesn't do much other than properly run the system's dexopt binary with the right arguments.

Credits:

Inspired by a script by Decad3nce

zip binary: taken from metamorph app's googlecode site.

dexopt-wrapper binary: Not in CM, so taken from random mediafire link

Author unknown, but here's what could be the source code