First you need to understand working of .apk and .odex file.
.Odex file:
Odex
file is the extracted and optimized DEX
file (classes.dex) from APK or JAR files
.
An ODEX file has dependencies on every file in the BOOTCLASSPATH that is loaded when it is generated.
The odex file is only valid when used with these exact BOOTCLASSPATH files.
Android Application 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.
It also makes hacking those applications difficult because a part of the coding has already been extracted to another location before execution.
How it work:-
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.
You can find some information Here and
Here is one StackOverFlow question may helpful to you.