[Galaxy S II Themes and Apps] sicopat:
The purpose of this thread is to give basics to manually deodex and odexing back framework and apk files​

Credits and Thanks to

:

Theory

:

Prerequisites

:

You will need these files

:

all included in the attached .zip (end of post)

You will also need

:

You have to know

:

* even on stock firmware (odexed) there are some deodexed .apk (like framework-res.apk in /system/framework/ and like some .apk in system/app/)

Tip on Windows "Vista / 7"

: open a CMD prompt in a specified folder

Manually Deodexing

:

theory

:

1/ put in the same folder :

2/ open CMD prompt in this folder (see above for how to)

3/ Deodexing Framework file (I will take android.policy.jar for example) :

* BAKSMALI of the android.policy.odex :

java -Xmx1024m -jar baksmali.jar -c :core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar -x [B]android.policy.odex[/B]

* This create an out folder. You can now modify some files (like adding Advanced power menu)

* SMALI the /out folder in a classes.dex file :

java -Xmx1024m -jar smali.jar [B]out[/B] -o classes.dex

* finally deodex your android.policy.jar :

4/ Deodexing APK in system/app (I will take SystemUI.apk for exemple) :

* BAKSMALI of the SystemUI.odex :

java -Xmx1024m -jar baksmali.jar -c :am.jar:android.policy.jar:android.test.runner.jar:bmgr.jar:bouncycastle.jar:com.android.location.provider.jar:com.google.android.maps.jar:com.samsung.device.jar:com.yamaha.android.media.jar:core.jar:core-junit.jar:ext.jar:framework.jar:ime.jar:input.jar:[B]java.awt.jar[/B]:javax.obex.jar:libvtmanagerjar.jar:monkey.jar:pm.jar:sec_feature.jar:seccamera.jar:sechardware.jar:secmediarecorder.jar:services.jar:sqlite-jdbc.jar:svc.jar:twframework.jar -x [B]SystemUI.odex[/B]

* an out folder is created. You can modify the files inside if you want.

* SMALI the /out folder in a classes.dex file :

java -Xmx1024m -jar smali.jar [B]out[/B] -o classes.dex

* finally deodex your SystemUI.apk :

* extra step for APKs : zipaplign of your new deodexed SystemUI.apk

--> In the same CMD prompt windows, type :

zipalign -v 4 SystemUI.apk zip_SystemUI.apk

A zip_SystemUI.apk file is created. Delete your deodexed SystemUI.apk and

rename

zip_SystemUI.apk in SystemUI.apk

ODEXING BACK :

the theory

:

How To

:

1/ backup your original files (apk jar and odex) to /sdcard/Mod/

2/ copy modified deodexed files (.apk and .jar) in /system/framework/ of your GS2

Now we are going to odex back :)

3/ open a CMD prompt in the folder of adb.exe (usualy /android-sdk-windows/platform-tools/)

4/ type command :

adb shell
su
## for .JAR file :
dexopt-wrapper /system/framework/XXX.jar /system/framework/patched_XXX.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

response must 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) ---

## for .APK file :
dexopt-wrapper /system/framework/XXX.apk /system/framework/patched_XXX.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

--> This will create the patched_XXX.odex file

Now we need to copy signature from original .odex file to patched .odex file cause Dalvik need files signature integrity in order to boot.

5/ always in the same CMD prompt windows :

# if not already done ...
adb shell
su

# copy the original .odex and .jar in system/framework (not .apk) :
cp /sdcard/MOD/original.XXX.odex /system/framework
cp -f /sdcard/MOD/XXX.jar /system/framework # where XXX.jar is the original odexed .jar

# give all permissions to XXX.odex files :
chmod 777 /system/framework/original.XXX.odex
chmod 777 /system/framework/patched_XXX.odex

# copy signature :
busybox dd if=/system/framework/original.XXX.odex of=/system/framework/patched_XXX.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

response must 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 over the patched_XXX.odex

Notice

:

a - if you don't have response after busybox dd command : busybox is not installed or you have a to old version, use the busybox included in the attached .zip

b - if you don't have the last response line : 20 byt