Post Reply

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

OP BreatheHT

2nd August 2012, 08:17 AM   |  #1  
BreatheHT's Avatar
OP Senior Member
Flag Diamond Bar
Thanks Meter: 203
 
297 posts
Join Date:Joined: Mar 2012
Donate to Me
More
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 )

Big thanks to JSLEnterprises, see him in #4. He provided a newer busybox for Scott's method.
Last edited by BreatheHT; 2nd August 2012 at 05:09 PM.
The Following 31 Users Say Thank You to BreatheHT For This Useful Post: [ View ]
2nd August 2012, 09:00 AM   |  #2  
theking_13's Avatar
Senior Member
Flag Florida
Thanks Meter: 1,467
 
7,378 posts
Join Date:Joined: Dec 2011
More
If you can, send me a PM on how to odex apps.

Sent from my HTC One X using Tapatalk 2
2nd August 2012, 09:56 AM   |  #3  
scrosler's Avatar
Recognized Developer
Flag Fargo
Thanks Meter: 52,250
 
23,867 posts
Join Date:Joined: Feb 2007
Donate to Me
Quote:
Originally Posted by BreatheHT

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?...l-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...

Quote:
Originally Posted by theking_13

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://forum.xda-developers.com/show....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 by scrosler; 2nd August 2012 at 10:07 AM.
The Following 5 Users Say Thank You to scrosler For This Useful Post: [ View ]
2nd August 2012, 10:21 AM   |  #4  
JSLEnterprises's Avatar
Senior Member
Flag Hamilton
Thanks Meter: 1,342
 
1,330 posts
Join Date:Joined: Apr 2011
Donate to Me
More
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.



Update: Busybox 1.20.2 has been released (though not compiled for android use yet)
Attached Files
File Type: zip busybox.zip - [Click for QR Code] (709.8 KB, 48 views)
Last edited by JSLEnterprises; 2nd August 2012 at 11:01 PM.
The Following 2 Users Say Thank You to JSLEnterprises For This Useful Post: [ View ]
2nd August 2012, 04:53 PM   |  #5  
Senior Member
Thanks Meter: 104
 
1,036 posts
Join Date:Joined: Aug 2006
Great stuff guys.
2nd August 2012, 04:57 PM   |  #6  
BreatheHT's Avatar
OP Senior Member
Flag Diamond Bar
Thanks Meter: 203
 
297 posts
Join Date:Joined: Mar 2012
Donate to Me
More
Quote:
Originally Posted by scrosler

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?...l-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://forum.xda-developers.com/show....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...
2nd August 2012, 05:06 PM   |  #7  
BreatheHT's Avatar
OP Senior Member
Flag Diamond Bar
Thanks Meter: 203
 
297 posts
Join Date:Joined: Mar 2012
Donate to Me
More
Quote:
Originally Posted by theking_13

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

Sent from my HTC One X using Tapatalk 2

You confused bro?
2nd August 2012, 05:18 PM   |  #8  
iElvis's Avatar
Recognized Contributor
Flag Modville
Thanks Meter: 1,893
 
3,761 posts
Join Date:Joined: May 2012
More
Thanks. Even though I won't ever be doing this, it's good to know what's going on.
2nd August 2012, 06:00 PM   |  #9  
Skizzy034's Avatar
Senior Member
Flag Amsterdam, NY
Thanks Meter: 1,010
 
4,954 posts
Join Date:Joined: Mar 2010
This is awesome. Thanks so much for this. I wanted to know how to odex and deodex roms.

Sent from my HTC One XL using xda app-developers app
2nd August 2012, 06:01 PM   |  #10  
Skizzy034's Avatar
Senior Member
Flag Amsterdam, NY
Thanks Meter: 1,010
 
4,954 posts
Join Date:Joined: Mar 2010
Quote:
Originally Posted by scrosler

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?...l-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://forum.xda-developers.com/show....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

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in One X General by ThreadRank