ODEX and DEODEX are terms that are thrown around a lot when we're talking about Custom ROMs. Some ROMs are DEODEXED, others are not. What does that mean and why do we have them?

If you haven't already watched the last couple episodes of Android Power User, you might want to. In those episodes we talk about the JIT Compiler, and the Dalvik Cache and Dalvik VM. If you've already watched those or have a solid understanding of them, let's dive right in!

Android apps are stored in .APK files (that stands for "Android Package", in case you were wondering). Like we talked about, the files themselves aren't pre-compiled, at least not in the traditional meaning of the word. Dalvik instead uses .DEX and .ODEX files to help speed things along.

What is an .ODEX file?

An .ODEX file is an "optimized Dalvik executable" file, sort of like an .EXE in windows. The .ODEX is compressed to save space, and contains bits and pieces of its application that are optimized before Android boots. This helps speed up the boot process and pre-loads parts of the application.

The downside? To save space, the .ODEX file contains parts of the program and the .APK contains the rest. That means it's fairly difficult to get inside an .ODEX file to make changes, whereas it's fairly easy to make changes inside an .APK.

What is DEODEX?

First off, it's not a file extension like .ODEX is, rather, apps that are DEODEXed are assembled in such a way that they aren't "pre-optimized" and the bits that would have gone into a separate .ODEX file are put into classes.dex files and kept inside the .APK. This allows for easy modification and theming.

Most Custom ROMs come DEODEXed.

Where does Zipalign fit in?

According to Developer.Android.com, Zipalign is an "archive alignment tool that provides important optimization to Android application (.apk) files". It's an extra step that all developers are advised to do before releasing their app to the public. Zipaligning one's app makes sure that all its uncompressed data "starts with a particular alignment relative to the start of the file". There's a lot of technical reasoning behind this, but the overall benefit is a reduction in the amount of RAM that is used while the zipaligned app is running.