[HowTo] Odex FRAMEWORK, all Android versions may apply.

Search This thread

BreatheHT

Senior Member
Mar 14, 2012
302
204
Diamond Bar
Here in this tutorial, I will show some facts about Deodex and Odex, then explain how to odex the framework of a ROM(which is pretty annoying, you'll find out). Credits goes to myself ;)

This method should work on all Android devices.

------------------------------------------------------------------------------------------------------------

First of all, what is odex? Something you should know about classes.dex.

Odex stands for Optimized dex. I'm not gonna explain a lot because I'm not sure if I'm right. First of all, in typical apk files, when you open it with WinRAR or something like that, you can find a file called "classes.dex"(this type of apk is deodexed). This file is the key. It contains the core codes of the apk. However the other type of apk comes with an *.odex file and doesn't have classes.dex inside the apk file. This is odexed apk. There are 2 types of ROMs here, odexed and deodexed. Odexed ROMs' classes.dex are already out of the apk files, while deodexed ROMs' classes.dex are still in the apks. When Android executes an apk, it has to extract the classes.dex out and execute it. So when you flash an deodexed ROM, the first boot takes a long long time since the Android system needs to extract all the classes.dex into dalvik-cache(it shows "Optimizing apks" on the screen for 4.0 ROMs, shows boot animation on screen for 2.3 or below ROMs). However for the odexed ROMs, because the classes.dex are already out there, the system just grabs them and use them, without wasting time and storage space extracting classes.dex out.

Why odex framework?

It can boost your device a little by odexing your framework. Your phone can run more efficiently. Although it's a complicated process, but trust me, it's worth it.

What is so special about odexing framework files? What's the difference?

Odexing an app is very easy, and I believe everyone knows how to do it. But odexing framework is really annoying. Why? Because apps and more like stand-alone things, they are not a part of system. You delete it, nothing bad happens, your phone still boots, you just get endless FC if you delete the wrong one, or missing status bar, that's all. But framework files you cannot mess around. They are parts of the system. They have to match the system's codes precisely, without any error, even the order of files(keep this in mind, very important). So for every ROM, the framework initialize codes are different(same RUU or other ROM based ROMs count as its base ROM), and you must modify the odexing binary to make it odex for you properly, or you can sit and watch the beautiful bootloop.

What's the relationship between odexing apps and odexing framework?

Simple, but important. If you odexed apps, you cannot touch the framework. Framework always goes in the first place. If you wanna odex both, you must odex framework first. Or... "The Tragedy of App and Framework"...

So what do we have to keep in mind before we start?

Keep your mind clear, prepare a bag of ice in case you feel dizzy with the codes, and MAKE ENOUGH SPACE FOR FRAMEWORK ODEXING. I would prefer you remove a few useless apks in /system/app first to make more room in system partition. Failing odexing may brick your device forever! Nah just kidding ;) it will only cause you to bootloop. No big deal. Also, it won't odex your framework-res.apk and always will not, so don't feel bad and do it again and again till your phone burn ;). Make sure your device is ROOTED and enable USB debug. You need Java Runtime Environment.

What tools do you need?

Notepad++ and a magical rar that contains all you need to success.

Let's get started.

------------------------------------------------------------------------------------------------------------

1. Use your file manager to find init.rc at the very root directory of your phone and copy it to SDCard for later code editing, or you simply adb pull it out and skip the coping step. (If you know how to compile boot.img it is even easier, just unpack boot in Android Kitchen, look for line "export BOOTClassPATH". I'm not gonna introduce that method since most people can't. Silly me, didn't I just intoduced that? XD)

2. Connect USB, set mode as disk drive so you can access your SDCard. Copy init.rc into your computer. Open it with notepad, and find where it says "export BOOTClassPATH", create a new file and copy line "export BOOTClassPATH" into the new file. For example:
Code:
export BOOTCLASSPATH/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar:/system/framework/HTCExtension.jar:/system/framework/com.htc.framework.jar:/system/framework/com.htc.android.pimlib.jar:/system/framework/com.htc.android.easopen.jar:/system/framework/com.scalado.util.ScaladoUtil.jar:/system/framework/com.orange.authentication.simcard.jar:/system/framework/android.supl.jar:/system/framework/com.ecrio.sip.jar

3. Open dexopter in the rar you downloaded with Notepad++. Find the lines that show the similar contents to the things after "export BOOTClassPATH". It is Line 21 to Line 35 on my laptop. Edit them according to the things you just copied out of init.rc. For example, if the first file is "X.jar", then you will have to edit the line into "dexopt-wrapper/system/framework/X.jar /system/framework/X.odex". Then repeat until you finish with all the files that are listed in the long list you copied out of init.rc. File order DOES MATTER. Use the bag of ice I told you to prepare eariler to make you sober if you feel dizzy with the codes. The lines may be more or less after you edited them, doesn't matter.

4. Copy "dexopter" and "dexopt-wrapper" into /system/bin and set the correct permissions. Make sure they have enough permission to change your system files. Restart your phone.

5. Go to CMD and lead it to where adb.exe is(included in the rar). Type these in order:
Code:
adb shell
su
cd system/framework
dexopter fr
Then the codes will run crazy in your cmd window... The odex process has begun!

6. If the odex process completed without error, you are half way there! Well it doesn't mean you have to stare at your screen during the process. It's about time we figure it out! The phone will automatically reboot once it's finished. If it doesn't and you are sure all are done, reboot manually.

7. If you can't boot properly, go back and check everything carefully. If you can, then open your file manager and copy the entire framework directory into your SDCard. You can still adb pull and skip the next coping step.

8. Mount SDCard. Go into framework directory on your computer. Open every file that has an odex file with it, delete the classes.dex inside. WinRAR is okay. The files may seem ridiculously small after you delete the classes.dex, but don't worry since classes.dex are already pulled out and turned into odex files.

9. Copy the whole framework folder into the folder where adb is at. Use adb to push all the files back into /system/framework.
Code:
adb root
adb remount
adb push framework /system/framework
adb shell
su
chmod /system/framework xxx (xxx is a permission code, depends on your ROM. They should be the same as the old deodexed framework files. Use Google to find out how to use the permission codes.)

10. After all the files are pushed in, reboot your phone.

11. If it still boots into the system, congratulations! You've successfully odexed your framework! If it doesn't, then go back and read everything carefully. The most common error occurs when you are editing the dexopter code. You will have to redo everything again.

Done! Everything is ready to go!

You can directly grab the files you've odexed and put it in your custom ROM(must be the same base), just don't forget the odex files.

------------------------------------------------------------------------------------------------------------

Okay, hmm, what to say now? Still, I would be glad if you donated me, but if you don't it's okay, just reply and hit thanks ;).

Oh almost forgot, the magical rar: http://d-h.st/tYi

------------------------------------------------------------------------------------------------------------

Big thanks to Scott, see him in #3. He explained why some files aren't odexed and provided a easier method(but they all get you dizzy :p)

Big thanks to JSLEnterprises, see him in #4. He provided a newer busybox for Scott's method.
 
Last edited:

Scott

Retired Recognized Developer
Here in this tutorial, I will show some facts about Deodex and Odex, then explain how to odex the framework of a ROM(which is pretty annoying, you'll find out). Credits goes to myself ;)


Also, it won't odex your framework-res.apk and always will not, so don't feel bad and do it again and again till your phone burn ;). Make sure your device is ROOTED and enable USB debug. You need Java Runtime Environment.

Good write up. Other files that wont "re-odex" are com.htc.resources.apk, com.htc.videowidget.res.apk, com.htc.weather.res.apk and framework-htc-res.apk.

The reason? The files dont have .dex files because there is no code in them. These files just carrier resources like images (for those that didint know).

The .dex files are the actual smali code that devs mod to make the ROM do crazy things ;)

Also, an easier method can be found here: http://themikmik.com/showthread.php?12988-Tool-App-Dexo-the-Universal-Odex-Utility
It does it all and pulls the bootclass for you. And it also does /system/app/ in one simple shot.


Also, one last thing... You can just as easily pull the files back to the PC using the ADB Pull command...

Code:
adb pull /system/app ./app
adb pull /system/framework/ ./framework

EDIT: And another simple method to get your bootclass is do another ADB Pull

Code:
add pull init.rc

I find the adb pull method quicker and more simple...

If you can, send me a PM on how to odex apps. :)

Sent from my HTC One X using Tapatalk 2

You can use the method I just explained or if you want to try the framework manually then do apps seperately then you can use this: http://xdaforums.com/showthread.php?t=1514576
I use that app to re-odex updated files in the ROM. For example... If Gmail updates (which it just did) I would remove the old gmail files from system/app/ and put the new one in and run that program then pull the files.

-Scott
 
Last edited:

JSLEnterprises

Senior Member
Apr 26, 2011
1,349
1,360
Buenos Aires
If anyone finds this to be too much work... dont worry... it only unpacks the classes.dex once. It will only need to unpack a dex if original file has changed (changed entries need to propogate). That's why all the consecutive boots are back to a 'normal' span of time.

re-odexing your roms IS recommended if either A) you're anal-retentive/have OCD or B) propogation ("Android is Upgrading...") happens every time you reboot your device (it happens sometimes)

If you're going to use the tool scrosler linked to, replace the busybox binary with the one inside the attatched zip (this is busybox 1.20.1). The one that come with the tool is pretty dated.

:good:

Update: Busybox 1.20.2 has been released (though not compiled for android use yet)
 

Attachments

  • busybox.zip
    709.8 KB · Views: 123
Last edited:

BreatheHT

Senior Member
Mar 14, 2012
302
204
Diamond Bar
Good write up. Other files that wont "re-odex" are com.htc.resources.apk, com.htc.videowidget.res.apk, com.htc.weather.res.apk and framework-htc-res.apk.

The reason? The files dont have .dex files because there is no code in them. These files just carrier resources like images (for those that didint know).

The .dex files are the actual smali code that devs mod to make the ROM do crazy things ;)

Also, an easier method can be found here: http://themikmik.com/showthread.php?12988-Tool-App-Dexo-the-Universal-Odex-Utility
It does it all and pulls the bootclass for you. And it also does /system/app/ in one simple shot.


Also, one last thing... You can just as easily pull the files back to the PC using the ADB Pull command...

Code:
adb pull /system/app ./app
adb pull /system/framework/ ./framework

EDIT: And another simple method to get your bootclass is do another ADB Pull

Code:
add pull init.rc

I find the adb pull method quicker and more simple...



You can use the method I just explained or if you want to try the framework manually then do apps seperately then you can use this: http://xdaforums.com/showthread.php?t=1514576
I use that app to re-odex updated files in the ROM. For example... If Gmail updates (which it just did) I would remove the old gmail files from system/app/ and put the new one in and run that program then pull the files.

-Scott

hehe yep I know the adb pull command, I thought about it and I didn't put it in... :p
 

Skizzy034

Senior Member
Mar 10, 2010
5,509
1,123
40
Amsterdam, NY
www.facebook.com
Good write up. Other files that wont "re-odex" are com.htc.resources.apk, com.htc.videowidget.res.apk, com.htc.weather.res.apk and framework-htc-res.apk.

The reason? The files dont have .dex files because there is no code in them. These files just carrier resources like images (for those that didint know).

The .dex files are the actual smali code that devs mod to make the ROM do crazy things ;)

Also, an easier method can be found here: http://themikmik.com/showthread.php?12988-Tool-App-Dexo-the-Universal-Odex-Utility
It does it all and pulls the bootclass for you. And it also does /system/app/ in one simple shot.


Also, one last thing... You can just as easily pull the files back to the PC using the ADB Pull command...

Code:
adb pull /system/app ./app
adb pull /system/framework/ ./framework

EDIT: And another simple method to get your bootclass is do another ADB Pull

Code:
add pull init.rc

I find the adb pull method quicker and more simple...



You can use the method I just explained or if you want to try the framework manually then do apps seperately then you can use this: http://xdaforums.com/showthread.php?t=1514576
I use that app to re-odex updated files in the ROM. For example... If Gmail updates (which it just did) I would remove the old gmail files from system/app/ and put the new one in and run that program then pull the files.

-Scott

Is there also a tool to deodex roms?

Sent from my HTC One XL using xda app-developers app
 

techlogik

Senior Member
Aug 23, 2006
1,853
306
Is there also a tool to deodex roms?

Sent from my HTC One XL using xda app-developers app

Like Scott posted?

Basically that is the steps right there..you are doing the apk in the system/app and framework.

That link provides a tool which when done properly will run on the de-odexed stock Rom and odex it...

Good luck with that...it's a nightmare...haha..
 

JSLEnterprises

Senior Member
Apr 26, 2011
1,349
1,360
Buenos Aires
Is there also a tool to deodex roms?

Sent from my HTC One XL using xda app-developers app

http://xdaforums.com/showthread.php?t=1208320
(you'll have to update the versions included in the zip as this thread is dated - 2011)

Note: the API level for 4.0.3/4.0.4 (what our HOX's run) is '15'.

you can also use DSIXDA's kitchen which can be used to batch deodex apk's after you set the api level
(it's defaulted to '10'... which was Gingerbread -> 2.3.3-2.3.7)

Full list of API levels for their specific Android versions
 
Last edited:

Scott

Retired Recognized Developer
hehe yep I know the adb pull command, I thought about it and I didn't put it in... :p
Yeah, I like to do it better that way. Dont have to move my hands from the keyboard and mouse. Makes you more efficient :good:

Most official ROMs are odexed.
I think all?

Quite the opposite where I come from
Although I came from a different carrier so this side of the forums is different

Sent from my HTC One X using Tapatalk 2

Carrier is irrelevant. Most people dont know how to work with ODEX files so they go with de-odex. Its mroe challanging but provides a better experience.

Like Scott posted?

Basically that is the steps right there..you are doing the apk in the system/app and framework.

That link provides a tool which when done properly will run on the de-odexed stock Rom and odex it...

Good luck with that...it's a nightmare...haha..

No he is asking to go the other way from odex to de-odex.

Yep Android Kitchen can do it.

http://xdaforums.com/showthread.php?t=1208320
(you'll have to update the versions included in the zip as this thread is dated - 2011)

Note: the API level for 4.0.3/4.0.4 (what our HOX's run) is '15'.

you can also use DSIXDA's kitchen which can be used to batch deodex apk's after you set the api level
(it's defaulted to '10'... which was Gingerbread -> 2.3.3-2.3.7)

Full list of API levels for their specific Android versions

Yep, I love that script. I was the one that sent him the mnt point file for the HOX :highfive:

I am going to talk to him about bringing in "official" support for the Asus TF300T. I got the boot.img fiugred out this morning! Woot. **** is about to get real with the Asus!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 31
    Here in this tutorial, I will show some facts about Deodex and Odex, then explain how to odex the framework of a ROM(which is pretty annoying, you'll find out). Credits goes to myself ;)

    This method should work on all Android devices.

    ------------------------------------------------------------------------------------------------------------

    First of all, what is odex? Something you should know about classes.dex.

    Odex stands for Optimized dex. I'm not gonna explain a lot because I'm not sure if I'm right. First of all, in typical apk files, when you open it with WinRAR or something like that, you can find a file called "classes.dex"(this type of apk is deodexed). This file is the key. It contains the core codes of the apk. However the other type of apk comes with an *.odex file and doesn't have classes.dex inside the apk file. This is odexed apk. There are 2 types of ROMs here, odexed and deodexed. Odexed ROMs' classes.dex are already out of the apk files, while deodexed ROMs' classes.dex are still in the apks. When Android executes an apk, it has to extract the classes.dex out and execute it. So when you flash an deodexed ROM, the first boot takes a long long time since the Android system needs to extract all the classes.dex into dalvik-cache(it shows "Optimizing apks" on the screen for 4.0 ROMs, shows boot animation on screen for 2.3 or below ROMs). However for the odexed ROMs, because the classes.dex are already out there, the system just grabs them and use them, without wasting time and storage space extracting classes.dex out.

    Why odex framework?

    It can boost your device a little by odexing your framework. Your phone can run more efficiently. Although it's a complicated process, but trust me, it's worth it.

    What is so special about odexing framework files? What's the difference?

    Odexing an app is very easy, and I believe everyone knows how to do it. But odexing framework is really annoying. Why? Because apps and more like stand-alone things, they are not a part of system. You delete it, nothing bad happens, your phone still boots, you just get endless FC if you delete the wrong one, or missing status bar, that's all. But framework files you cannot mess around. They are parts of the system. They have to match the system's codes precisely, without any error, even the order of files(keep this in mind, very important). So for every ROM, the framework initialize codes are different(same RUU or other ROM based ROMs count as its base ROM), and you must modify the odexing binary to make it odex for you properly, or you can sit and watch the beautiful bootloop.

    What's the relationship between odexing apps and odexing framework?

    Simple, but important. If you odexed apps, you cannot touch the framework. Framework always goes in the first place. If you wanna odex both, you must odex framework first. Or... "The Tragedy of App and Framework"...

    So what do we have to keep in mind before we start?

    Keep your mind clear, prepare a bag of ice in case you feel dizzy with the codes, and MAKE ENOUGH SPACE FOR FRAMEWORK ODEXING. I would prefer you remove a few useless apks in /system/app first to make more room in system partition. Failing odexing may brick your device forever! Nah just kidding ;) it will only cause you to bootloop. No big deal. Also, it won't odex your framework-res.apk and always will not, so don't feel bad and do it again and again till your phone burn ;). Make sure your device is ROOTED and enable USB debug. You need Java Runtime Environment.

    What tools do you need?

    Notepad++ and a magical rar that contains all you need to success.

    Let's get started.

    ------------------------------------------------------------------------------------------------------------

    1. Use your file manager to find init.rc at the very root directory of your phone and copy it to SDCard for later code editing, or you simply adb pull it out and skip the coping step. (If you know how to compile boot.img it is even easier, just unpack boot in Android Kitchen, look for line "export BOOTClassPATH". I'm not gonna introduce that method since most people can't. Silly me, didn't I just intoduced that? XD)

    2. Connect USB, set mode as disk drive so you can access your SDCard. Copy init.rc into your computer. Open it with notepad, and find where it says "export BOOTClassPATH", create a new file and copy line "export BOOTClassPATH" into the new file. For example:
    Code:
    export BOOTCLASSPATH/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar:/system/framework/HTCExtension.jar:/system/framework/com.htc.framework.jar:/system/framework/com.htc.android.pimlib.jar:/system/framework/com.htc.android.easopen.jar:/system/framework/com.scalado.util.ScaladoUtil.jar:/system/framework/com.orange.authentication.simcard.jar:/system/framework/android.supl.jar:/system/framework/com.ecrio.sip.jar

    3. Open dexopter in the rar you downloaded with Notepad++. Find the lines that show the similar contents to the things after "export BOOTClassPATH". It is Line 21 to Line 35 on my laptop. Edit them according to the things you just copied out of init.rc. For example, if the first file is "X.jar", then you will have to edit the line into "dexopt-wrapper/system/framework/X.jar /system/framework/X.odex". Then repeat until you finish with all the files that are listed in the long list you copied out of init.rc. File order DOES MATTER. Use the bag of ice I told you to prepare eariler to make you sober if you feel dizzy with the codes. The lines may be more or less after you edited them, doesn't matter.

    4. Copy "dexopter" and "dexopt-wrapper" into /system/bin and set the correct permissions. Make sure they have enough permission to change your system files. Restart your phone.

    5. Go to CMD and lead it to where adb.exe is(included in the rar). Type these in order:
    Code:
    adb shell
    su
    cd system/framework
    dexopter fr
    Then the codes will run crazy in your cmd window... The odex process has begun!

    6. If the odex process completed without error, you are half way there! Well it doesn't mean you have to stare at your screen during the process. It's about time we figure it out! The phone will automatically reboot once it's finished. If it doesn't and you are sure all are done, reboot manually.

    7. If you can't boot properly, go back and check everything carefully. If you can, then open your file manager and copy the entire framework directory into your SDCard. You can still adb pull and skip the next coping step.

    8. Mount SDCard. Go into framework directory on your computer. Open every file that has an odex file with it, delete the classes.dex inside. WinRAR is okay. The files may seem ridiculously small after you delete the classes.dex, but don't worry since classes.dex are already pulled out and turned into odex files.

    9. Copy the whole framework folder into the folder where adb is at. Use adb to push all the files back into /system/framework.
    Code:
    adb root
    adb remount
    adb push framework /system/framework
    adb shell
    su
    chmod /system/framework xxx (xxx is a permission code, depends on your ROM. They should be the same as the old deodexed framework files. Use Google to find out how to use the permission codes.)

    10. After all the files are pushed in, reboot your phone.

    11. If it still boots into the system, congratulations! You've successfully odexed your framework! If it doesn't, then go back and read everything carefully. The most common error occurs when you are editing the dexopter code. You will have to redo everything again.

    Done! Everything is ready to go!

    You can directly grab the files you've odexed and put it in your custom ROM(must be the same base), just don't forget the odex files.

    ------------------------------------------------------------------------------------------------------------

    Okay, hmm, what to say now? Still, I would be glad if you donated me, but if you don't it's okay, just reply and hit thanks ;).

    Oh almost forgot, the magical rar: http://d-h.st/tYi

    ------------------------------------------------------------------------------------------------------------

    Big thanks to Scott, see him in #3. He explained why some files aren't odexed and provided a easier method(but they all get you dizzy :p)

    Big thanks to JSLEnterprises, see him in #4. He provided a newer busybox for Scott's method.
    5
    Here in this tutorial, I will show some facts about Deodex and Odex, then explain how to odex the framework of a ROM(which is pretty annoying, you'll find out). Credits goes to myself ;)


    Also, it won't odex your framework-res.apk and always will not, so don't feel bad and do it again and again till your phone burn ;). Make sure your device is ROOTED and enable USB debug. You need Java Runtime Environment.

    Good write up. Other files that wont "re-odex" are com.htc.resources.apk, com.htc.videowidget.res.apk, com.htc.weather.res.apk and framework-htc-res.apk.

    The reason? The files dont have .dex files because there is no code in them. These files just carrier resources like images (for those that didint know).

    The .dex files are the actual smali code that devs mod to make the ROM do crazy things ;)

    Also, an easier method can be found here: http://themikmik.com/showthread.php?12988-Tool-App-Dexo-the-Universal-Odex-Utility
    It does it all and pulls the bootclass for you. And it also does /system/app/ in one simple shot.


    Also, one last thing... You can just as easily pull the files back to the PC using the ADB Pull command...

    Code:
    adb pull /system/app ./app
    adb pull /system/framework/ ./framework

    EDIT: And another simple method to get your bootclass is do another ADB Pull

    Code:
    add pull init.rc

    I find the adb pull method quicker and more simple...

    If you can, send me a PM on how to odex apps. :)

    Sent from my HTC One X using Tapatalk 2

    You can use the method I just explained or if you want to try the framework manually then do apps seperately then you can use this: http://xdaforums.com/showthread.php?t=1514576
    I use that app to re-odex updated files in the ROM. For example... If Gmail updates (which it just did) I would remove the old gmail files from system/app/ and put the new one in and run that program then pull the files.

    -Scott
    2
    If anyone finds this to be too much work... dont worry... it only unpacks the classes.dex once. It will only need to unpack a dex if original file has changed (changed entries need to propogate). That's why all the consecutive boots are back to a 'normal' span of time.

    re-odexing your roms IS recommended if either A) you're anal-retentive/have OCD or B) propogation ("Android is Upgrading...") happens every time you reboot your device (it happens sometimes)

    If you're going to use the tool scrosler linked to, replace the busybox binary with the one inside the attatched zip (this is busybox 1.20.1). The one that come with the tool is pretty dated.

    :good:

    Update: Busybox 1.20.2 has been released (though not compiled for android use yet)
    1
    Is there also a tool to deodex roms?

    Sent from my HTC One XL using xda app-developers app

    Yep Android Kitchen can do it.
    1
    Hopefully this will help to see more odex ROMs