[Android Software Development] TearsDontFalls:
Why this tutorial?

I made this tutorial for the galaxy 3, but then some user reported me that it worked on another phone, so I post this thread here again.

I wanted a good odexed rom, but there isn't any here. So I tried to make my own odexed rom, but it wasn't so good. So I read something about re-odexing and tried it out. I modified it a little bit and I don't know all about re-odexing, so if someone know something better, pls post it here in the thread for everyone. English is also not my mother language, but I hope you'll understand me

What is a odexed and a deodexed rom?

When you look at a stock rom in the folder /system/app, you will see files with the ending .odex and the apks doesn't contains classes.dex files. When you look at a deodexed rom, you'll see that there are no .odex files and the apks contains classes.dex files. Basically every apk contains a classes.dex files. Then the dalvik virtual machine generates a dalvik cache based of the classes.dex file. When you load a app, it will be loaded from the the dalvik cache, not from the apk. Samsung built the odexed rom using a tool called dexopt-wrapper. This tool generates .odex files based from the classes.dex, that means it does the same job like the dalvik vm. The .odex files were pushed in the /system. The files are the replacement for the dalvik cache. Like I wrote above, apps are loading from the dalvik cache, not from apk or classes.dex file, so classes.dex are not needed anymore, so they are deleted in odexed roms. Deodexing using xUltimate means regenerating a classes.dex based from the .odex file, merging it into the apk and deleting .odex.

What are the advantages and disadvantages from a deodexed rom?

Advantages:

-All needed things are in one apk, so modding/theming is (better) possible

-Needs less space on /system

Disavantages:

-Needs more space on /data

-Is not so stable than a odexed rom

-Slower on first boot(because a odexed rom has already execute ready .odex files, a deodexed rom needs to generate dalvik cache)

What do I need to re-odex?

-A rooted phone

-A full NANDroid Backup

-More than 30 mb free space on /system

-ADB drivers for Option 1

-Titanium Backup Pro for Option 2

How can I re-odex a Rom?

There are 2 Options to do it, but only the first does a full re-odex.

Before doing anything make sure that you have a full NANDroid Backup because you'll propably get into a bootloop and I cant guarantee that it works on your device/rom.

Option 1 using dexopt-wrapper:

I used first the script from puppet13th, but I got into a bootloop. So Ive done some changes and tried it until it worked

Some users told me that you can re-odex the rom without being in CWM, so you can may skip Step 2, but you could get into a bootloop without Step 2, but you can try it out, there is no risk with a NANDroid backup

Step 1: Configure the script for your device:

The attached script is made for the galaxy 3, so you have to configure the script for your device. If you done it, pls upload it and post it here for other users.

Download the zip(link below) for your system and unzip it. Then go to the folder "odex" and then open there the file/script "odex" with your favourite text editor(I suggest Notepad++).

You only have to replace the $BOOTCLASSPATH. You can find the valid $BOOTCLASSPATH in /init.rc. Enter your $BOOTCLASSPATH after "BOOTCLASSPATH=" for example so(beginning from Line 8):

BOOTCLASSPATH=replace_this_with_your_bootclasspath
cd /system/framework
for filename replace_this_with_your_bootclasspath

In the line

for filename replace_this_with_your_bootclasspath

you must replace the ":" character between framework files with a space.

Step 2(optional): Reboot your phone into cwm recovery and get adb access there

For best results you should re-odex in the recovery menu. Some users told me that it also works in a running system, so you can also try it in a running system, but you must mount /system rw before.

So if you want to re-odex in the recovery menu, reboot into recovery and make sure you have adb access.

Step 3: Ensure /system & /data is mounted, Connect your phone and run reodex script

Make sure that /system and /data is mounted in rw mode(in recovery: go to mount & storages, in a running system:use root explorer) and connect your phone with your computer.

You already downloaded the re-odex script in step 1. Your computer will push it over adb with the needed binaries to your phone. The script will create odex files, will delete classe.dex from the apk/jar, will rezipalign your apks and will delete the dalvik cache.

For windows users: double click on odex.cmd

For linux users: open a terminal and navigate to the folder which contains the unzipped attachment and run

chmod +x reodex.sh
./reodex.sh

After its finished, simply reboot and enjoy your fully re-odexed rom.

Step 4 (optional) convert /data:

I dont know if there is a better option, but after a re-odex with Option 1, my phone didnt showed the right free space on /data. So I converted /data to a other filesystem and back and then it showed the right free space.

So check your free space and if its wrong, convert your filesystem if you kernel support that.

Option 2 using Titanium Backup Pro:

You need to have Titanium Backup pro for re-odexing.

Step 1:

Select Menu -> More -> integrate sys dalvik into rom and wait until its finished. Then you should have more space on /data. I had when I tried it before 105 and after 135 mb free space on /data and 0kb free space after it on /system, so its not all.

You can also undo it. Its good when you want to try out a new theme, so you can undo and redo it using TB Pro.

Simply select Menu -> More -> Undo sys dalvik integration

and you're done.

Option 1 vs. Option 2

-Option 1 does a full re-odex, you have full free space on /data(Option 2 does only re-odex the apps in /system/app, not the framework(/system/framework)

-Option 1 deletes classes.dex from apks and jars(against Option 2), so you have more space free on /system

-You can undo Option 2 fast, so theming/modding is also possible by undo, theme and redo it, you can also undo Option 1, its called deodexing, but its not so fast

Download Links

XDA gaves me only 500 Errors when uploading was done, so I uploaded it to min.us

Re-Odex Script for Windows

Re-Odex Script for Linux(probably doesnt work, I cant reupload because I dont have the file anymore)

Working on...

There are only phones in the list, which were reported as working by users. It can aso work on a phone which isnt in the list.

Samsung Galaxy 3(working with default script)

HTC Amaze 4G(no script attached)

HTC Evo 4G(script here)

Samsung Galaxy S2(script here)

Motorola Atrix(script here)

Nexus S (4G)(script here)

XPeria Ray(script here)

SGS 1 maybe(working script for ICS aokp here and a working script for 2.3.6 (XWJW5) here)

Wildfire S(script here)

Nexus 7(script here)

TF700T & TF300T(script here)

Xperia Ray GB REPACK4PDA_V7(script here)

Acer A510 and Asus Transformer Prime TF201(script here)

Credits

puppet13th for making orginal script

If I helped you, you can press the thanks button under the post.