To begin, we need to know what an odex file is. It's a part of an application (the .apk file) that has been prebuilt to make the Dalvik Virtual Machine load it faster using less resources. If you look in the /system/app/ folder on your Android phone or tablet, you'll see that just about every application has both an .apk file and an .odex file. These files work together through the Dalvik VM to make the apps run as they should on our devices. Let's break it all down after the break.

Awesome question, Clark. And one I think we can answer in terms that most folks will understand. As you've noted, you see the terms odex and deodexed in many forums posts about custom ROMs or assorted hacks for phones and tablets both. It takes a lot of work for developers to create deodexed ROMs from "stock" ROMs, like the ones offered from both OEMs and Google alike.

What the heck does odex and deodex actually mean? I see the terms mentioned in almost every custom ROM thread and can't find an answer that I can understand. I'm hoping that Android Central can help out.

The Dalvik VM

The Dalvik VM is a big part of an Android system. It is the component that allows third party applications written in Java to run on your phone or tablet. The system itself starts the DVM up, and when you press to start an app it goes to work. It takes the data inside the .apk files and using a Just-in-time (JIT) compiler, it builds the information into a program, then runs it. Having portions of the code already optimized and built into a file that the DVM can run makes the process faster, and uses less resources. That's what an odex file is.

Odex files

The odex files you see in your system folder are built by the folks who wrote and built the application itself. Android apps are written in Java, then converted into bytecode. Then, they are converted from the standard Java Virtual Machine compatible .class files into a special type of file that the Dalvik VM can read. These are called .dex files. When these .dex files are placed outside the rest of the code (which is in the .apk file), you are left with a stand alone .odex file.

There are plenty of good reasons to have stand alone .odex files. They make boot times faster (especially the first boot), by building the Dalvik-cache as the system is booted. They also save some space by pointing to the Android framework whenever possible, and allow the application developer to optimize his or her programs. But having seperate.odex files isn't very hacker friendly.

Deodexing

Deodexing files means taking the stand alone .odex file and the .apk file, and rebuilding them so that all of this pre-built application information is contained inside the .apk file instead of its own file. The pre-built data for the Dalvik VM is now in a classes.dex file inside the .apk file, like in the picture above. That makes the .apk files a bit bigger, and they can't be pre-loaded when the system is fired up. But they can be reverse engineered by hackers and themers.

With all the code and data for the program in one place, you can use tools to "unbuild" the app and edit it however you like. This is how themes and tweaks like battery percentage mods are made for "stock" ROMs. After a developer makes his or her changes, they then rebuild the .apk file and the changes can run. This won't affect any other part of the system because none of the code or data is being shared with other apps.

Which should you choose?

That's really up to you, and what your needs will be, but I suggest flashing a deodex version whenever possible. Yes, odex ROMs boot faster, but you really only notice it on the very first boot when all the system apps are pre-cached by the Dalvik VM. You can also save a good bit of space by using odex files, but this space is all in the system partition and won't give you room for more apps if your phone or tablet uses a separate application partition. With todays modern phones and their multi-core processors and huge banks of RAM, you won't even notice any faster application loading times.

If you want to do things like change the status bar, or theme TouchWiz or Sense, you'll need a deodex ROM. You'll also need a deodex ROM to do some of the really cool deep system tweaks like changing the settings menu or edits to the framework. In short, if you've already unlocked your bootloader and rooted, and you're ready for a custom ROM, choosing a deodexed version is probably the best choice. You'll be amazed at the things these crazy developers can come up with, and you'll surely run into a few you want to try for yourself.