[GUIDE] Deodexing system/framework folder

What is the purpose of deodexing?

When you deodex your framework folder it's easier to make modifications (mods) to the framework. When you don't deodex the system/framework folder you will have to odex the files back. This guide is for all Xperia devices except for the ICS firmware of Xperia S since there is no deodexed system/framework yet of this firmware.


First of all you need to download the necessary files. You can find them here: download files

1) Extract all files to a folder on your pc
2) Copy dexopt-wrapper to your phone, in the folder /system/bin.
3) Copy the /system/framework folder contents to the same folder as your deodex files
4) install 7zip to make things easy.

That's all preparation you need, now we are ready to start deodexing.


To start deodexing you ned to know the BOOTHCLASSPATH of your device. For Xperia devices this is:


For deodexing you need to open a command prompt in the folder where all your files are located. You can do this by clicking shift key + right mouse button simultaniously. So open up a command prompt to get started. Now I'll explain how to deodex the files in the system/framework folder. You need to use this command:

java -Xmx1024m -jar baksmali.jar -c :core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:apache-xml.jar:filterfw.jar -x "filename".odex

You need to replace "filename" by the name of the file you want to deodex. So if you want to deodex framework.odex you need to use this command:

java -Xmx1024m -jar baksmali.jar -c :core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:apache-xml.jar:filterfw.jar -x framework.odex

This will create an out folder where the content of the .odex file will be placed. Now we need to put this content in a classs.dex file. This is very easy and is the same for all files:

java -Xmx1024m -jar smali.jar out -o classes.dex

Now you have a file called classes.dex in your folder. To complete the deodexing of framework.odex you need to open framework.jar with 7-zip. Now drag the classes.dex in the framework.jar file.

To deodex the remaining files in your framework folder follow the same process as above. deodex the odex file, make the classes.dex file and finally put the classes.dex file in the matching .jar file. But be aware:

always delete classes.dex and the out folder before deodexing a new file!

Odexing back.

This is only used when you have an odexed rom or firmware and you want to make framework mods for this firmware. After deodexing the file and making your modifications you need to odex the deodexed and edited file back to use it in your rom or firmware. I'll explain this using the framework.jar file used in the above tutorial for deodexing.

1) Copy the original framework.odex and framework.jar file to the sdcard/mod folder of your phone.
2) Rename the original framework.odex to original.framework.odex
3) Copy the new deodexed framework.jar to system/framework folder on your phone.
4) Open the command window again in the folder of your deodex files on your pc.
Type these commands to create a new .odex file:

adb shell
dexopt-wrapper /system/framework/XXX.jar /system/framework/patched_framework.odex /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

Your response should be:

--- BEGIN '/system/framework/android.policy.jar' (bootstrap=0) ---
--- waiting for verify+opt, pid=7194
--- would reduce privs here
--- END '/system/framework/android.policy.jar' (success) ---

Now we need to copy the signature from the original .odex file to your new created .odex file:

cp /sdcard/MOD/original.framework.odex /system/framework
cp -f /sdcard/MOD/framework.jar /system/framework>
chmod 777 /system/framework/original.framework.odex
chmod 777 /system/framework/patched_framework.odex
busybox dd if=/system/framework/original.framework.odex of=/system/framework/patched_framework.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

Your response should be:

busybox dd if=/system/framework/original.XXX.odex of=/system/framewor k/patched_XXX.odex bs=1 count=20 skip=52 seek=52 conv=notrunc
20+0 records in
20+0 records out
20 bytes (20B) copied, 0.002042 seconds, 9.6KB/s

Now the signature is copied to your new odex file. To use this file you just need to rename it to framework.odex and copy it over the old framework.odex file.