• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

Odex files deodexing and zipalign explained

Search This thread

cyanidekiller

Member
Mar 22, 2012
47
91
Sydney
When dealing with custom ROMs the terms ‘odexed’, ‘deodexed’ and ‘zipaligned’ are encountered quite often. In this tutorial we will explain what they mean and how they can affect your device.


In Short:

Odex files:

-Pre-optimized parts of application or library.

Deodexing:

- the process of combining .odex and .apk files in order to have the full code of the application in one place.

Zipalign:
- archive alignment tool used to optimize apk packages.

In Details:

Dex files:

Dalvik EXecutable (DEX) is a home-grown Android format used in Dalvik virtual machine. It does not use the same java bytecode instructions. Dalvik opcodes are designed to support the Java language, however compiling code to Dalvik bytecode written in other languages is possible. Android comes with a disassembler called dexdump.

Jar files:

Java ARchive (JAR) is an archive file format used to aggregate many Java class files and associated metadata and other resources (text, images, settings etc) into one file to distribute application software or libraries on the Java platform. In Android the difference is that JAR files instead of Java class files contain classes.dex file which contains the Dalvik bytecode. In Android you wil find those mostly in /system/framework.

Apk files:
Application package file(APK) is the file format used to distribute and install applications onto Google’s Android operating system. Apk files are ZIP file formatted packages based on the JAR file format, with .apk file extensions. An APK file normally contains

META-INF folder – contains manifest file, certificate and signature
res folder – not compiled resources
assets folder – more raw resources
resources.arsc – pre-compiled resources
AndroidManifest.xml – Android specific manifest file in binary xml
classes.dex – the java classes compiled in a DEX file.
Note that in Odexed ROMs classes.dex can be missing in APK and JAR files.

BOOTCLASSPATH:

BOOTCLASSPATH is a list of the jars/apk from which classes can be loaded, in addition to the main apk/jar that is loaded. Normally Android has 5 JAR files in it’s base BOOTCLASSPATH – core.jar, ext.jar, framework.jar, android.policy.jar and services.jar. However, some APK files have more dependencies on additional jar or apks files. Google maps for example needs com.google.android.maps.jar. To check your BOOTCLASSPATH you can type: ‘adb shell set’;



Odex files:

Odex file is actually 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. dalvik enforces this by storing a checksum of each file that the odex file is dependent on, and ensuring that the checksum for each file matches when the odex file is loaded.

Deodexing:

- the process of reassembling ODEX files in DEX(classes.dex) and place them pack in the respective APK and JAR files.

Android Applications Startup Process :

When an application is started on first use if no ODEX file is found, classes.dex is optimized by the package manager(PM) and saved in /data/dalvik-cache.

Odexed ROMs

In these ROMs you will have ODEX files for most APK and JAR files in /system/framework and /system/app and also the classes.dex in APK and JAR files will be missing.

pros::laugh::laugh::laugh:

Speed up loading as odex is uncompressed and already optimized
saves space as no need to put optimized dex in dalvik-cache (already have the ODEX file in /system/framework or /system/app)
Hard to hack/decompile as data is separated

cons::crying::crying::crying::crying:

cannot do modifications to apks or jars
cannot do theming
cannot change BOOTCLASSPATH if system libraries are affected
DeOdexed ROMs:
In these ROMs you will have classes.dex file in all APK and JAR files.


Pros::laugh:

can do modifications to apks
can do theming
can change/add/remove libraries and thus recompile all the current apks with the new implementation


Cons::crying:

slower loading but just the one time when a modification is done or dalvik-cache cleaned(wiped).
need to put optimized dex in dalvik-cache
easer to decompile an app


Zipalign:

- archive alignment tool used to optimize apk packages. Basically the data in the APK package is being read by many process (app itself , installer, home app, system server, etc.). If every process knows where to look for its data it wont need to unpack the whole APK. Zipaligned APKs are done in such a way so all uncompressed data starts with a particular alignment(on 4 byte boundaries) relative to the start of the file.




THANK ME IF THIS INFO HELPED YOU
.......:laugh::laugh:
 

andwise

Member
Jan 22, 2012
42
89
andwise.net
It is good to mention at least the source ESPECIALLY when you copy/paste

http://andwise.net/?p=419

thank you!


When dealing with custom ROMs the terms ‘odexed’, ‘deodexed’ and ‘zipaligned’ are encountered quite often. In this tutorial we will explain what they mean and how they can affect your device.


In Short:

Odex files:

-Pre-optimized parts of application or library.

Deodexing:

- the process of combining .odex and .apk files in order to have the full code of the application in one place.

Zipalign:
- archive alignment tool used to optimize apk packages.

In Details:

Dex files:

Dalvik EXecutable (DEX) is a home-grown Android format used in Dalvik virtual machine. It does not use the same java bytecode instructions. Dalvik opcodes are designed to support the Java language, however compiling code to Dalvik bytecode written in other languages is possible. Android comes with a disassembler called dexdump.

Jar files:

Java ARchive (JAR) is an archive file format used to aggregate many Java class files and associated metadata and other resources (text, images, settings etc) into one file to distribute application software or libraries on the Java platform. In Android the difference is that JAR files instead of Java class files contain classes.dex file which contains the Dalvik bytecode. In Android you wil find those mostly in /system/framework.

Apk files:
Application package file(APK) is the file format used to distribute and install applications onto Google’s Android operating system. Apk files are ZIP file formatted packages based on the JAR file format, with .apk file extensions. An APK file normally contains

META-INF folder – contains manifest file, certificate and signature
res folder – not compiled resources
assets folder – more raw resources
resources.arsc – pre-compiled resources
AndroidManifest.xml – Android specific manifest file in binary xml
classes.dex – the java classes compiled in a DEX file.
Note that in Odexed ROMs classes.dex can be missing in APK and JAR files.

BOOTCLASSPATH:

BOOTCLASSPATH is a list of the jars/apk from which classes can be loaded, in addition to the main apk/jar that is loaded. Normally Android has 5 JAR files in it’s base BOOTCLASSPATH – core.jar, ext.jar, framework.jar, android.policy.jar and services.jar. However, some APK files have more dependencies on additional jar or apks files. Google maps for example needs com.google.android.maps.jar. To check your BOOTCLASSPATH you can type: ‘adb shell set’;



Odex files:

Odex file is actually 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. dalvik enforces this by storing a checksum of each file that the odex file is dependent on, and ensuring that the checksum for each file matches when the odex file is loaded.

Deodexing:

- the process of reassembling ODEX files in DEX(classes.dex) and place them pack in the respective APK and JAR files.

Android Applications Startup Process :

When an application is started on first use if no ODEX file is found, classes.dex is optimized by the package manager(PM) and saved in /data/dalvik-cache.

Odexed ROMs

In these ROMs you will have ODEX files for most APK and JAR files in /system/framework and /system/app and also the classes.dex in APK and JAR files will be missing.

pros::laugh::laugh::laugh:

Speed up loading as odex is uncompressed and already optimized
saves space as no need to put optimized dex in dalvik-cache (already have the ODEX file in /system/framework or /system/app)
Hard to hack/decompile as data is separated

cons::crying::crying::crying::crying:

cannot do modifications to apks or jars
cannot do theming
cannot change BOOTCLASSPATH if system libraries are affected
DeOdexed ROMs:
In these ROMs you will have classes.dex file in all APK and JAR files.


Pros::laugh:

can do modifications to apks
can do theming
can change/add/remove libraries and thus recompile all the current apks with the new implementation


Cons::crying:

slower loading but just the one time when a modification is done or dalvik-cache cleaned(wiped).
need to put optimized dex in dalvik-cache
easer to decompile an app


Zipalign:

- archive alignment tool used to optimize apk packages. Basically the data in the APK package is being read by many process (app itself , installer, home app, system server, etc.). If every process knows where to look for its data it wont need to unpack the whole APK. Zipaligned APKs are done in such a way so all uncompressed data starts with a particular alignment(on 4 byte boundaries) relative to the start of the file.




THANK ME IF THIS INFO HELPED YOU
.......:laugh::laugh:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 59
    When dealing with custom ROMs the terms ‘odexed’, ‘deodexed’ and ‘zipaligned’ are encountered quite often. In this tutorial we will explain what they mean and how they can affect your device.


    In Short:

    Odex files:

    -Pre-optimized parts of application or library.

    Deodexing:

    - the process of combining .odex and .apk files in order to have the full code of the application in one place.

    Zipalign:
    - archive alignment tool used to optimize apk packages.

    In Details:

    Dex files:

    Dalvik EXecutable (DEX) is a home-grown Android format used in Dalvik virtual machine. It does not use the same java bytecode instructions. Dalvik opcodes are designed to support the Java language, however compiling code to Dalvik bytecode written in other languages is possible. Android comes with a disassembler called dexdump.

    Jar files:

    Java ARchive (JAR) is an archive file format used to aggregate many Java class files and associated metadata and other resources (text, images, settings etc) into one file to distribute application software or libraries on the Java platform. In Android the difference is that JAR files instead of Java class files contain classes.dex file which contains the Dalvik bytecode. In Android you wil find those mostly in /system/framework.

    Apk files:
    Application package file(APK) is the file format used to distribute and install applications onto Google’s Android operating system. Apk files are ZIP file formatted packages based on the JAR file format, with .apk file extensions. An APK file normally contains

    META-INF folder – contains manifest file, certificate and signature
    res folder – not compiled resources
    assets folder – more raw resources
    resources.arsc – pre-compiled resources
    AndroidManifest.xml – Android specific manifest file in binary xml
    classes.dex – the java classes compiled in a DEX file.
    Note that in Odexed ROMs classes.dex can be missing in APK and JAR files.

    BOOTCLASSPATH:

    BOOTCLASSPATH is a list of the jars/apk from which classes can be loaded, in addition to the main apk/jar that is loaded. Normally Android has 5 JAR files in it’s base BOOTCLASSPATH – core.jar, ext.jar, framework.jar, android.policy.jar and services.jar. However, some APK files have more dependencies on additional jar or apks files. Google maps for example needs com.google.android.maps.jar. To check your BOOTCLASSPATH you can type: ‘adb shell set’;



    Odex files:

    Odex file is actually 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. dalvik enforces this by storing a checksum of each file that the odex file is dependent on, and ensuring that the checksum for each file matches when the odex file is loaded.

    Deodexing:

    - the process of reassembling ODEX files in DEX(classes.dex) and place them pack in the respective APK and JAR files.

    Android Applications Startup Process :

    When an application is started on first use if no ODEX file is found, classes.dex is optimized by the package manager(PM) and saved in /data/dalvik-cache.

    Odexed ROMs

    In these ROMs you will have ODEX files for most APK and JAR files in /system/framework and /system/app and also the classes.dex in APK and JAR files will be missing.

    pros::laugh::laugh::laugh:

    Speed up loading as odex is uncompressed and already optimized
    saves space as no need to put optimized dex in dalvik-cache (already have the ODEX file in /system/framework or /system/app)
    Hard to hack/decompile as data is separated

    cons::crying::crying::crying::crying:

    cannot do modifications to apks or jars
    cannot do theming
    cannot change BOOTCLASSPATH if system libraries are affected
    DeOdexed ROMs:
    In these ROMs you will have classes.dex file in all APK and JAR files.


    Pros::laugh:

    can do modifications to apks
    can do theming
    can change/add/remove libraries and thus recompile all the current apks with the new implementation


    Cons::crying:

    slower loading but just the one time when a modification is done or dalvik-cache cleaned(wiped).
    need to put optimized dex in dalvik-cache
    easer to decompile an app


    Zipalign:

    - archive alignment tool used to optimize apk packages. Basically the data in the APK package is being read by many process (app itself , installer, home app, system server, etc.). If every process knows where to look for its data it wont need to unpack the whole APK. Zipaligned APKs are done in such a way so all uncompressed data starts with a particular alignment(on 4 byte boundaries) relative to the start of the file.




    THANK ME IF THIS INFO HELPED YOU
    .......:laugh::laugh:
    7
    It is good to mention at least the source ESPECIALLY when you copy/paste

    http://andwise.net/?p=419

    thank you!


    When dealing with custom ROMs the terms ‘odexed’, ‘deodexed’ and ‘zipaligned’ are encountered quite often. In this tutorial we will explain what they mean and how they can affect your device.


    In Short:

    Odex files:

    -Pre-optimized parts of application or library.

    Deodexing:

    - the process of combining .odex and .apk files in order to have the full code of the application in one place.

    Zipalign:
    - archive alignment tool used to optimize apk packages.

    In Details:

    Dex files:

    Dalvik EXecutable (DEX) is a home-grown Android format used in Dalvik virtual machine. It does not use the same java bytecode instructions. Dalvik opcodes are designed to support the Java language, however compiling code to Dalvik bytecode written in other languages is possible. Android comes with a disassembler called dexdump.

    Jar files:

    Java ARchive (JAR) is an archive file format used to aggregate many Java class files and associated metadata and other resources (text, images, settings etc) into one file to distribute application software or libraries on the Java platform. In Android the difference is that JAR files instead of Java class files contain classes.dex file which contains the Dalvik bytecode. In Android you wil find those mostly in /system/framework.

    Apk files:
    Application package file(APK) is the file format used to distribute and install applications onto Google’s Android operating system. Apk files are ZIP file formatted packages based on the JAR file format, with .apk file extensions. An APK file normally contains

    META-INF folder – contains manifest file, certificate and signature
    res folder – not compiled resources
    assets folder – more raw resources
    resources.arsc – pre-compiled resources
    AndroidManifest.xml – Android specific manifest file in binary xml
    classes.dex – the java classes compiled in a DEX file.
    Note that in Odexed ROMs classes.dex can be missing in APK and JAR files.

    BOOTCLASSPATH:

    BOOTCLASSPATH is a list of the jars/apk from which classes can be loaded, in addition to the main apk/jar that is loaded. Normally Android has 5 JAR files in it’s base BOOTCLASSPATH – core.jar, ext.jar, framework.jar, android.policy.jar and services.jar. However, some APK files have more dependencies on additional jar or apks files. Google maps for example needs com.google.android.maps.jar. To check your BOOTCLASSPATH you can type: ‘adb shell set’;



    Odex files:

    Odex file is actually 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. dalvik enforces this by storing a checksum of each file that the odex file is dependent on, and ensuring that the checksum for each file matches when the odex file is loaded.

    Deodexing:

    - the process of reassembling ODEX files in DEX(classes.dex) and place them pack in the respective APK and JAR files.

    Android Applications Startup Process :

    When an application is started on first use if no ODEX file is found, classes.dex is optimized by the package manager(PM) and saved in /data/dalvik-cache.

    Odexed ROMs

    In these ROMs you will have ODEX files for most APK and JAR files in /system/framework and /system/app and also the classes.dex in APK and JAR files will be missing.

    pros::laugh::laugh::laugh:

    Speed up loading as odex is uncompressed and already optimized
    saves space as no need to put optimized dex in dalvik-cache (already have the ODEX file in /system/framework or /system/app)
    Hard to hack/decompile as data is separated

    cons::crying::crying::crying::crying:

    cannot do modifications to apks or jars
    cannot do theming
    cannot change BOOTCLASSPATH if system libraries are affected
    DeOdexed ROMs:
    In these ROMs you will have classes.dex file in all APK and JAR files.


    Pros::laugh:

    can do modifications to apks
    can do theming
    can change/add/remove libraries and thus recompile all the current apks with the new implementation


    Cons::crying:

    slower loading but just the one time when a modification is done or dalvik-cache cleaned(wiped).
    need to put optimized dex in dalvik-cache
    easer to decompile an app


    Zipalign:

    - archive alignment tool used to optimize apk packages. Basically the data in the APK package is being read by many process (app itself , installer, home app, system server, etc.). If every process knows where to look for its data it wont need to unpack the whole APK. Zipaligned APKs are done in such a way so all uncompressed data starts with a particular alignment(on 4 byte boundaries) relative to the start of the file.




    THANK ME IF THIS INFO HELPED YOU
    .......:laugh::laugh: