Android - What is the difference between odexed and deodexed ROMs?
A .dex
file is basically a compiled bytecode version of an app that has been built for the Dalvik VM which Android's apps run on. I believe it is short for Dalvik Executable, but I'm not sure if I'm remembering that correctly.
An .odex
file is an Optimized .dex
file (hence the 'o'), meaning that it has basically been pre-compiled for a specific platform. The advantage to this is that startup time is much faster since the VM doesn't have to perform any optimizing at startup/runtime. The disadvantages are 1) That it takes up some extra space and 2) An odexed app won't run properly if it's put onto another device, and it must have the associated .odex
file to run at all.
ROMs are typically released in deodexed form because they can be themed and modified fairly easily, whereas theming/modifying an odexed ROM is basically impossible (at best things would crash like crazy). Some people also choose to release their ROMs in odexed versions for people who would prefer the performance gains.
Most of the stock ROMs I've seen are odexed, I assume because the carriers/manufacturers want the performance boost. They also don't have any kind of official theming methods, so they probably don't care if you can't change the colors of your status icons or your system text or whatnot. Plus they have the advantage of knowing what device they want their system to run on, so they can pre-compile the .odex
files very easily, I imagine. As an added bonus, it makes it difficult to pull .apk
files off of the device and share them with people.
Edit: Since I just realized that I was not very explicit about the difference here - an "odexed" ROM is one where the apps have been precompiled, and thus contain associated .odex
files which are external to the .apk
files. A "deodexed" ROM is one where data that would be optimized in the .odex
files has been more or less merged back into the .apk
files (meaning it is not optimized but basically platform agnostic), thus the .apk
files are self-contained and there are no .odex
files. This is usually just done with a deodexing utility, such as smali/baksmali.
I personally wanted to know the answer to this a little while ago. Here is what I came up with:
Odexed and Deodexed
A standard ROM is supposed to be odexed for release which provides smoother and faster loading of apps into memory. Each .apk has a corresponding .odex. When the application is used by either the system or the user, the .odex is used to start loading the app. A ROM that is deodexed has only the .apk file. When the application is called into memory from only pulling the data from it’s .apk, this takes longer due to not being optimized for easier retrieval from the system.
Common questions that I get asked way too often are:
- Why do custom ROM’s deodexed?
- Should I use a odexed or a deodexed ROM?
To answer these questions it comes down to one word, themability. If you talk to anyone that themes ROM’s they will tell you that it’s extremely easier to theme a deodexed ROM. Since we started using deodexed ROM’s, themers could now create themes to apply to a ROM rather than the tedious option to theme the ROM itself (release a custom ROM for a theme). If you use a odexed ROM and try to apply themes, it will not work or only theme some visual aspects, which will give you a terrible user interface to experience.
Deodex Cons
I bet you are now wondering why… why is there even an option to download a custom ROM that is odexed? The answer to that is speed. Remember how I said that odexed files are optimized for easier retrieval? Simply put… it’s optimized (like indexing a data table) so the system can open the .apk faster.
Deodex and zipalign
Everyone wanted the best of both worlds so quickly after the deodexed trend started to peak, these savvy ROM developers came up with a solution to zipalign at boot. This optimizes each .apk on every reboot which then allows the system to access applications more efficiently and most importantly, faster. Of course, the disadvantage is slightly slower boot times.
Summary
If you have a choice to download the custom ROM odexed or deodexed, I would just go with the deodex ROM. You never know when you would want to try out a theme or do some modifications yourself and it’s nice to have easy options rather than flashing a whole new ROM. With newer devices you may not even see a noticeable difference to zipalign on boot. If your device is pretty slow and outdated, well then I would suggest to think about this a little harder. I would bet some of you would prefer to get a nice minimal optimized (odexed) ROM for better performance and speed over customizing the user interface.
If you're new the subject you can find some common terms located on my original write-up here: http://codeversed.com/deodexed-vs-odexed-rom
Otherwise, the above shows you everything you need to know. If I missed anything, please let me know :)
A .dex (dalvik executable) file is basically similar to Windows' .exe files (except in Dalvik VM's language, instead of compiled code). Basically, .odex (optimized dalvik executable) and deodex (de-optimized dalvik executable) relates to how resource files are handled in the applications. The .odex is a .dex file that have been optimized by the dexopt program: http://www.netmite.com/android/mydroid/dalvik/docs/dexopt.html
Advantage
- odex is faster
- it makes themeing easier
Disadvantage
- deodex is slower on first startup
- the .odex files makes theming harder