What Is Odex And Deodex In Android [Complete Guide]

As an Android newbie, what bothered me most was coming across terminology beyond my comprehension. Not coming from a Linux background it became hard to keep up with the oh-so-commonly-used words spread all across the development community. Likewise, since I didn’t understand the terms, consequently I was unable to determine is something was of any use to me or not. From what I have seen, this problem extends to many novice and even average users.

One commonly occurring word when playing with custom ROMs and firmware, and even themes is deodexed and odexed. Most users fail to understand what these terms actually imply, and while developers would boast again and again about their themes and ROMs being deodexed, the average user is left clueless as to what is going on.

In this article, we’ll try to explain what odexed and deodexed means, and what implications does it bring to a casual user.

WHAT IS AN ODEX FILE?

In Android file system, applications come in packages with the extension .apk. These application packages, or APKs contain certain .odex files whose supposed function is to save space. These ‘odex’ 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.

THEN COMES DEODEX

Deodexing is basically repackaging of these APKs in a certain way, such that they are reassembled into classes.dex files. By doing that, all pieces of an application package are put together back in one place, thus eliminating the worry of a modified APK conflicting with some separate odexed parts.

In summary, Deodexed ROMs (or APKs) have all their application packages put back together in one place, allowing for easy modification such as theming. Since no pieces of code are coming from any external location, custom ROMs or APKs are always deodexed to ensure integrity.


HOW THIS WORKS

For the more geeky amongst us, Android OS uses a Java-based virtual machine for running applications, called the Dalvik Virtual Machine. A deodexed, or .dex file contains the cache used by this virtual machine (referred to as Dalvik-cache) for a program, and it is stored inside the APK. An .odex file, on the other hand, is an optimized version of this same .dex file that is stored next to the APK as opposed to inside it. Android applies this technique by default to all the system applications.

Now, when an Android-based system is booting, the davlik cache for the Davlik VM is built using these .odex files, allowing the OS to learn in advance what applications will be loaded, and thus speeds up the booting process.

By deodexing these APKs, a developer actually puts the .odex files back inside their respective APK packages. Since all code is now contained within the APK itself, it becomes possible to modify any application package without conflicting with the operating system’s execution environment.

ADVANTAGES & DISADVANTAGES

The advantage of deodexing is in modification possibilities. This is most widely used in custom ROMs and themes. A developer building a custom ROM would almost always choose to deodex the ROM package first, since that would not only allow him to modify various APKs, but also leave room for post-install theming.

On the other hand, since the .odex files were supposed to quickly build the dalvik cache, removing them would mean longer initial boot times. However, this is true only for the first ever boot after deodexing, since the cache would still get built over time as applications are used. Longer boot times may only be seen again if the dalvik cache is wiped for some reason.

For a casual user, the main implication is in theming possibilities. Themes for android come in APKs too, and if you want to modify any of those, you should always choose a dedoexed custom ROM.

Was this article helpful? If you are confused with some other terms and want us to help explain them, please let us know in the comments.

Advertisement
  • Pingback: What Is zipalign In Android And How It Works [Complete Guide]

  • Pingback: Install Rooted Android 2.2 Froyo J29 ROM On Samsung Epic 4G

  • Pingback: Install Android 2.3 Gingerbread UI ROM On Motorola Defy

  • Pingback: Install eVoKINGS Android 2.3 Gingerbread ROM On HTC EVO 4G

  • Pingback: Install EViO Shift Rooted Android 2.2 FroYo ROM on HTC EVO 4G

  • drakko1980

    Thx for the article… helped me alot on building my rom

    • Joel

      I found more info about android here

      • Junior

        Wow, Joel. You actually posted a link to your own article and said you “found” more information there? I fell for it and checked out that horrifyingly written article that was almost impossible to comprehend. My head hurts.

  • Abdur Rahman

    I want to work in Odex.

  • JdgM3NT4L

    Thanks for breaking it down in an understandable and intuitive way. It really made a lot of sense and I for one am truly grateful.

  • Pingback: Install Rooted Android 2.3.3 Gingerbread ROM on S-OFF HTC Incredible S

  • vaeadr

    Clear and concise. Thanks very much for laying that out in plain language.

  • framram

    Thanks. The explanation us better than many other websites.

  • clarky

    Very helpful explaination. The question I have then is, when installing apps from the Market, Amazon, Handango or just side loading an APK downloaded from a forum or the like, are they odex or deodex? Will they sometimes be one and sometimes be the other? How would we know and how will they interact with whichever version of ROM we have? Will odex APKs cause problems on a deodex ROM and vis versa?

    • http://twitter.com/Harold Harold

      Did you ever find out the answer to these questions? I’d also like to know if “normal” .apk files will cause problems with Deodexed ROMs…

      • brachinus

        Side loaded and market apks are user apps, not system apps. This does not apply for them

        • http://twitter.com/Harold Harold

          Thanks for clearing that up!

        • purple

          What about when I want to integrate one app that I downloaded from Play store into a deodexed rom? Is this a problem? If it is, how can this be done?

          • wengkle

            what brachinus said.

  • shadowvlican

    thanks for explaining this so clearly!!

  • Prithvi Raj

    Thanks a lot for the clear explanation, I was scratching my head before reading this.

  • Vishal Mistry

    Love the way you explained it.. this would enable users (like me) choose among different custom roms and get exactly wat they want!!
    Thank a tonn..

  • Caga Regras

    Brilliant explanation! Thank you OP!

  • KrustyKrabs

    Very understandable explanation. Good work. Big Thanks!

  • Vishwa

    Thanks mate. It’s a valuable article.
    What did you mean by “odexed are Optimized”? optimized in terms of performance or memory?

  • Niko

    Hi Aatif,
    Thanks for this clear posting!

  • DrWallnut

    Thanks, I learned something today!

  • Pingback: Gain Root On Amaze 4G By Installing Pre-Rooted ROM [Guide]

  • vk

    Brilliant, clear, perfect article. Thanks!

  • Arek

    Clear, crisp and useful. Thank you!

  • Pradeep

    Thanks a ton, learned something today :)

  • Myphoto

    thank you

  • Greatwyrmm

    Great work on this instructional piece guys. Helps me out tramendously. You guys rock

  • Hharanh_g

    Wont the cache build from the .dex files inside the APK ??

  • Mike Lee

    Very well done. Thank you.

  • drkalo

    nice and simple explanation. Thanks.

  • Ecks

    thanks! very helpful..

  • Blunts

    Thank you for the excellent explanation

  • http://twitter.com/unwiredtech Patrick Sarmiento

    Great article for Android newbies

  • Popcorn

    Nice Article !

  • harish ramaiah

    thanks for the post have been breaking my head from long time on this :)
     

  • http://www.facebook.com/shreyas.kukde Shreyas Kukde

    that was helpful :D

  • DMC

    this is a great, i do understand what are the meaning of it.

    Tahnks Aatif

  • Lami

    Thanks !

  • DarkSoldier

    Nice explanation!!! Thanks a lot!!!

  • Philip Griffiths

    does this mean that I could delete all my .odex files and other than a first, longer boot my android would run ok afterwards?

    • Ali

      No, you could not just delete your .odex files, you would need to repackage them as a “classes.dex” file then put that classes.dex file into the apk. You would have to do this for all system applications. If you were to just delete the odex all your apps would stop working.

  • NiZ

    Only place in the web that provides a full (clear) explanation about this subject.
    Thanks!

  • garbagehunter

    Rubbish article.Information is scattered , and the issue doesn’t seem that hard to explain.maybe some drawings will help understanding.

    • TommyToolbox

      Did you notice that most everyone found the article clear and helpful? Perhaps you would benefit from some reading and comprehension skills training along with some thoughts on civility in you responses. AND you may be a visual learner which still doesn’t excuse you disparaging remark.

  • Thankful

    wow great explaination ty!

  • ozone

    Plz tell me what is HW video encoding/decoding

    • http://www.facebook.com/lee.ashton.3538 Lee Ashton

      HW encoding is where the CPU does the encoding, SW encoding is where the encoding program does the encoding (also applies for decoding)

      • Yuusha

        Uh, no. An application can’t do shit without a CPU. HW encoding/decoding is where the graphics processor does the work, while SW encoding/decoding is where the CPU does the work.

  • CynWytch

    Thanks so much for that explanation…it’s all starting to come into focus now!! :)

  • epikvision

    Wow, this was very informative. Another step towards Android mastery.

  • Lean

    THANKS!!! please keep understanding and sharing how does android work, there is almost no clear info about this around internet.

  • James

    I know this is old, but I still send this link to someone when they ask me about odex and deodex. deserves a bump.

  • jahid

    i want to work in odex. how can i do this?????????

  • warlord

    thanks

  • Dilip

    Thanks…. Good article……..

  • xyzi

    In post, odex speed up the boot proces..

    What boot?

    A system boot process, just when you turn on the device?

    Or a application boot process, when every time you lunching the apps?

  • xyzi

    As I understandDalvik VM preloads part of Application, and builds Dalvik cache, from odex file.
    Then maybe without odex, Dalvik VM builds cache by extracting portion of apk file.
    Is it right?

    Then odex just help Dalvik VM build Dalvik cache faster. Then booting will be faster.

    Dalvik VM speeds up the application lunching.

    Is it right?

  • Rohit

    Beauty of an article!!! :D

  • http://www.facebook.com/avastadi Putu Klungkung

    I Like you.. This is helpful.

  • Vignesh

    Thanks for the great article. Very clearly explained.

  • varun

    Thanks a lot for a very informative article.

  • Nacos

    Excellent explanation!

  • http://www.facebook.com/MarcelopMuniz Marcelo Muniz

    Thank you a lot man, you realy did it get across…

  • Juzer Ali

    Thanks a lot. Keep up the awesome work, guys!

  • truejake2

    Very helpful! Thanks! I’m an advanced windows user and a novice linux user so a lot of it could be very confusing but I keep catching up thanks to articles like yours.

  • Tech_Geek_Guy

    Thank you. I always wondered what that meant. Now as I was reading this, I was wondering if I would ever be faced with a scenario where I had to install a deodexed apk on a odexed Rom, or vise versa. Would there be any issues? Would it even work? Would I even have to worry about such a scenario? Thanks in advance for the info!

  • Arundeep Bharj

    VERY helpful!! Thank a lot:)

  • W00rm

    Is this an OS feature? I mean if you have to specify to your application that it is possible to build this files. And, in my device, the odex for the google play (vending) is not created, is this fact application design based or os based?

  • sina

    thanks bro!!! very clear and helpful

  • SRI

    Seriously needed this information for me, Lots of Thanks….

  • Mark

    Thank you!

  • ddevine

    I come from a Linux background – we don’t use most of the terminology you find in the phone modding community. The phone modding community is its own special type of animal only distantly related to the Linux community.

  • Steve Rowe

    Great summary. Thanks for the clear explanation!

  • Wahoo

    Wow. Thanks for the explanation!

  • Ryan

    Awesome article, thanks!

  • Rosrog

    Thanks a gazillion. Very grateful for this information.

  • nidou bossy

    Great info to learn before proceeding.

  • katanyoo3652@gmail.com

    ดี

  • FAGGOTCUNTFACE

    HI

    • cuntfacefaggot

      Nice name.

  • Ocean

    Damn , explaining so much for me.

  • sandip bansode

    i have changed framework.odex file then it gives me “stale dependancy error ” plz let me know if you have any solution of this error….”Thanks “

  • waterlubber

    Thanks, cleared up a lot about Link2SD.

  • Ahmed

    hats off for you guys !! and that was awesome .. now I understand how custom ROMs are built .. and I’m gonna try to build my own ROM