Post Reply

[Complete Guide] What is Odex and Deodex ROM?

21st March 2013, 10:31 AM   |  #1  
R_a_z_v_a_n's Avatar
XDA: ASSIST
OP Recognized Contributor
XDA Assist Team
Thanks Meter: 1,774
 
2,066 posts
Join Date:Joined: Sep 2009
More
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.

What is an DEODEX file?

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.

So, 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 majority noobs amongst us, Android OS uses a Java-based virtual machine 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.

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.

Advanteges & 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.

Note:Themes for android come in APKs too, and if you want to modify any of those, you should always choose a dedoexed custom ROM.
Last edited by R_a_z_v_a_n; 25th July 2013 at 11:13 AM.
The Following 132 Users Say Thank You to R_a_z_v_a_n For This Useful Post: [ View ]
21st March 2013, 10:50 AM   |  #2  
R_a_z_v_a_n's Avatar
XDA: ASSIST
OP Recognized Contributor
XDA Assist Team
Thanks Meter: 1,774
 
2,066 posts
Join Date:Joined: Sep 2009
More
[Guide] What is Zipalign and how to make Apps zipaligned
What is Zipalign?

Zipalign is an archive alignment tool introduced first time with 1.6 Android SDK (Software Development Kit). It optimizes the way an Android application package (APK) is packaged. Doing so enables the Android operating system to interact with the application more efficiently, and hence has the potential to make the application and overall the whole system much faster. Execution time is minimized for zipaligned applications, resulting is lesser amount of RAM consumption when running the APK.

How does it exact work?

In an Android operating environment, data files stored in each application package are accessed by multiple processes, for example, the installer will read the data manifest to determine the associated permissions; the system server can read these resources for multiple reasons, like displaying notifications; the Home application, for example, will read resources to get the application’s name and icon. Since Android is based on a a true multi-tasking operating infrastructure, these files are continually and repeatedly accessed. Finally, but not least, the application itself reads the manifest data.

As Android is Linux-based, memory-mapping plays a key role in efficient handling of processes. Essentially, the optimal alignment for the Android OS’ resource-handling code is 4-byte boundaries. What this means is that, if APKs are memory-mapped to 4-byte boundaries, and aligned accordingly, the OS will not need to ‘read through’ the whole application package to get to the desired data manifest. Every system process will know in advance where to look for it’s desired resources, and hence will execute much smoother and faster.

Summing it up, zipaligning an APK results in all uncompressed data within the package to be aligned on 4-byte boundaries, allowing all portions to be accessed directly with the memory-map. RAM consumption is lowered while execution because the querying code doesn’t have to read through the entire application package.

Disavantages of unaligned APKs

Quite understandably, situation would be reserved for unaligned application packages. Resource reading would be slow and memory usage would be on the higher end of the spectrum. It would also depend on how many unaligned applications are present. For example, if less number of applications with an unaligned home application, you’d see slower application launch times. This is the best case scenario. For a worst case scenario, having a number of unaligned applications will result in the system repeatedly starting and killing processes, struggling with lags and huge battery drain.


How to make APKs zipaligned?

As mentioned earlier, the zipalign tool became a part of Android SDK from 1.6 onwards. It can be found under the ‘tools’ folder of the SDK. To use it, simply run the command:

Quote:

zipalign [-f] [-v] <alignment> infile.apk outfile.apk

...where infile.apk is the source file, and outfile.apk is the output file.

You can also verify the alignment of an APK file using the following command:

Quote:

zipalign -c -v <alignment> existing.apk

...where existing.apk can be any application package that you need to get verified. Also, the <alignment> tag in both the commands needs to be an integral value (otherwise the command will return invalid). This value, although can be any integer, MUST always be 4, which would provide 32-bit alignment. Any other value and it will effectively do nothing.


Finally, for the flags used in these commands,

Quote:

-f - overwrites existing outfile.zip
-v - will give verbose output
-c - will confirm the alignment of a given file



CAUTION: Zipalign operation must only be performed after you have signed the APK file with your private key. If zipaligned before signing, the signing procedure will disturb the alignment. Same holds true for any other alteration, addition or removal to the APK file. Any change after running zipalign will undo the alignment.

Source: addictivetips
The Following 50 Users Say Thank You to R_a_z_v_a_n For This Useful Post: [ View ]
21st March 2013, 10:53 AM   |  #3  
R_a_z_v_a_n's Avatar
XDA: ASSIST
OP Recognized Contributor
XDA Assist Team
Thanks Meter: 1,774
 
2,066 posts
Join Date:Joined: Sep 2009
More

Quote:

Update 16.11.2013

[ODEX][SCRIPT/TOOL] Odexer Tool 1.0 Beta 2 (11-14-2013)
[SCRIPT TO ODEX] Universal Odex Script Version 6.3.1 (11-03-2013)
Quote:

Credits & Thanks for this tool:

MatrixDJ96

Last edited by R_a_z_v_a_n; 19th November 2013 at 01:25 PM. Reason: Tutorials - deodex, re-odex and other stuff
The Following 9 Users Say Thank You to R_a_z_v_a_n For This Useful Post: [ View ]
21st March 2013, 11:01 AM   |  #4  
GaYoung28's Avatar
Senior Member
Flag D:/Forum/Felix/Location/Indonesia
Thanks Meter: 82
 
415 posts
Join Date:Joined: Oct 2012
Donate to Me
More
Re: [Complete Guide] What is Odex and Deodex ROM?
I think you just must create 1 thread titled "About Android" or someting like that
BTW it is good to know that:thumbup::thumbup:

Sent from my GT-I9070 using xda app-developers app
21st March 2013, 11:15 AM   |  #5  
R_a_z_v_a_n's Avatar
XDA: ASSIST
OP Recognized Contributor
XDA Assist Team
Thanks Meter: 1,774
 
2,066 posts
Join Date:Joined: Sep 2009
More
This materials are not created by me, I just searched and read carefully over the WWW in an attempt to bring as much informations to our forum S. Advance.
Only this was my job, along with the desire to know the phone held.

In my opinion, one thread with all the information is difficult to manage, because of that i'm so reluctant in what concerns for easy finding by members.
The Following 4 Users Say Thank You to R_a_z_v_a_n For This Useful Post: [ View ]
21st March 2013, 01:19 PM   |  #6  
Sami Kabir's Avatar
Senior Member
Flag Zinj
Thanks Meter: 858
 
1,813 posts
Join Date:Joined: Oct 2012
Donate to Me
More
Re: [Complete Guide] What is Odex and Deodex ROM?
Make a Guide on how to (Re)Odex a Deodexed ROM if possible...

Sent from my GT-I9070 using xda app-developers app
The Following User Says Thank You to Sami Kabir For This Useful Post: [ View ]
21st March 2013, 01:23 PM   |  #7  
R_a_z_v_a_n's Avatar
XDA: ASSIST
OP Recognized Contributor
XDA Assist Team
Thanks Meter: 1,774
 
2,066 posts
Join Date:Joined: Sep 2009
More
Flash stock ROM?
The Following 2 Users Say Thank You to R_a_z_v_a_n For This Useful Post: [ View ]
21st March 2013, 02:45 PM   |  #8  
Sami Kabir's Avatar
Senior Member
Flag Zinj
Thanks Meter: 858
 
1,813 posts
Join Date:Joined: Oct 2012
Donate to Me
More
Quote:
Originally Posted by R_a_z_v_a_n

Flash stock ROM?

Hahahaha.. but I wasn't Joking.. people say that its always better Re-Odex a Deoxed app after editing it
21st March 2013, 03:37 PM   |  #9  
R_a_z_v_a_n's Avatar
XDA: ASSIST
OP Recognized Contributor
XDA Assist Team
Thanks Meter: 1,774
 
2,066 posts
Join Date:Joined: Sep 2009
More
Understand now. Let me do some research and read what to do in that sense ...
The Following User Says Thank You to R_a_z_v_a_n For This Useful Post: [ View ]
9th April 2013, 09:13 PM   |  #10  
sanderg's Avatar
Senior Member
Thanks Meter: 48
 
228 posts
Join Date:Joined: Aug 2009
More
Smile
Quote:
Originally Posted by Sami Kabir

Make a Guide on how to (Re)Odex a Deodexed ROM if possible...

Make it very short then.
Odex Me

(Post useful? Hit the Thanks button etc.)
Last edited by sanderg; 9th April 2013 at 09:13 PM. Reason: typo

The Following User Says Thank You to sanderg For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
deodex, guide, odex, zipalign
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Galaxy S Advance I9070 General by ThreadRank