FORUMS
Remove All Ads from XDA

[HOW TO][Windows]Extract Deodex Sign and Zipalign an official ROM

808 posts
Thanks Meter: 960
 
By sicopat, Senior Member on 20th June 2011, 09:31 PM
Post Reply Email Thread
Hi,
Just want to share tools I found in order to :

Quote:

- Extract SGS2 stock firmwares :

* Use sgs2toext4.jar Application from drphrozen to convert .img files to ext4.img
* Then MOUNT ans EXTRACT ext4.img with Diskinternals Linux Reader : Here


- Deodex, sign and zippalign :

with this deodex kit : _Kit_Deodexage.zip


- Create your CWM customROM (wype script)

using a Skeleton ROM : Custom_ROM GS2 by SicOpaT.zip

Nothing from me, just reporting for you
Links at the end of post (or in changeLog)


EDIT 16/08 :
1/ update of Kit_deodexage with last versions of smali/baksmali v1.2.7 to avoid LAG bug of browser
2/ add of Custom_ROM GS2 by SicOpaT_v2.zip with a new CWM script NON WIPE
To customise the CWM script, go to Custom_ROM GS2 by SicOpaT.zip\META-INF\com\google\android and edit updater-script with notepad ++


Step by step guide
:

Preparation :
Quote:

1/ Extract Custom_ROM GS2 by SicOpaT.zip in order to have a folder with the same name (your future customROM)
2/ Extract sgs2toext4.zip to sgs2toext4.jar and put it in C:\
3/ Extract _Kit_Deodexage.zip to a folder of the same name
4/ install Diskinternals Linux Reader : Here
5/ Install Java SE Development Kit (JDK) if not already installed : Here

Extracting the stock ROM :
1/ open your stock__firmware.tar with 7-zip or winRAR
2/ extract in C:\ :
Quote:

factoryfs.img,
cache.img (if you have 3 tar files in your firmware, extract cache.img from CSC.tar)
modem.bin
zImage : your kernel

* Extracting KERNEL and PHONE part :
Quote:

3/ put zImage and modem.bin in the root folder of : Custom_ROM GS2 by SicOpaT (next to META_INF)


* Extracting Factoryfs.img :
Quote:

4/ Double click sgs2toext4.jar, a windows is opening :



5/ drag factoryfs.img in the sgs2converter.jar windows
factoryfs.ext4.img is created

6/ Open Diskinternals Linux Reader
Code:
> Drives > Mount Image > browse to your factoryfs.ext4.img > Mount
Then a new drive appears in the Diskinternals window, called Linux native Volume > double click on it

7/ Select all and press Save > Next > Browse to Custom_ROM GS2 by SicOpaT/System/ check for Save directory structure and then press Next > Next > Finish
8/ In Diskinternals click Back and then right click to your Linux volume and select unmount


* Extracting cache.img :
Quote:

9/ Double click sgs2toext4.jar
10/ drag cache.img in the sgs2converter.jar windows
cache.ext4.img is created

11/ Mount cache.ext4.img in diskinternals

12/ In your linux drive goto \recovery and save sec_csc.zip
Don't save it in your Custom_ROM GS2 by SicOpaT folder

13/ Extract sec_csc.zip (same structure as an update.zip)

14/ Copy everything in /system exept /app to Custom_ROM GS2 by SicOpaT/system
like here :


Now you can unmount and close diskinternal, we have done with extracting the ROM


Now time to Deodex, sign and zipalign : with the _Kit_Deodexage script
Quote:



1/ in Custom_ROM GS2 by SicOpaT/system/ MOVE everything in the app folder to _Kit_Deodexage/app

3/ in Custom_ROM GS2 by SicOpaT/system/ MOVE everything in the framework folder to _Kit_Deodexage/framework

4/ Press : Deodex_Gingerbread.cmd and it will
- deodex
- sign
- zipalign
4 bis/ edit after beginning of deodexing process the NePasSigner.txt and add samsung apps

5/ 2 folders are created : Deodex_framework and Deodex_app

6/ verify that the /app and /framework folders are empty

6/ Move everything from /Deodex_framework exept java.awt.jar to Custom_ROM GS2 by SicOpaT/system/framework

7/ Move everything from Deodex_app to Custom_ROM GS2 by SicOpaT/system/app


Buid your CWM update.zip :
Quote:

With WinRAR : CTRL A in your custonROM root folder and Right Click > Add to Archive > ZIP and None or Normal compression

That's all ! You have a stock customROM fully deodexed, signed and zipaligned




PS : You should change the Kernel for the CF-Root Kernel (CWM Manager ...) changing the zImage with the zImage from ChainFire CF-Root

PS 2 : You can add some apps (like Titanium backup) in the /data/app folder of your customROM

EDIT 1 : The deodexed browser.apk obtained will be bugy : Lag scrolling
Since pulser_g2 found the FIX, DEVs used an old deodexed browser.apk (from KE2 ROM for example).
So pulser_g2 foung the FIX, in order to avoid this Lag trouble using the last deodexed browser.apk (KF2 for example). You can see the How To FIX yourself the laggy browser.apk following advices from pulser_g2 in the changeLog of 07/03/2011.

EDIT 2 : just added a zip of an META_INF folder witch can be used for update over a previous deodexed customROM with same signature (a previous ROM built with the same script).
With this META_INF, you will not loose any data/cache



Credits :

Quote:

Thanks to drphrozen for sgs2toext4.jar and sgs2converter.jar tools
Thanks to xeudoxus for his custom java.awt.jar (deodexing some apks without errors)
Thanks to Okarin for his Deodex script
Thanks to Pulser-g2 for the laggy Browser Fix
Thanks to omrij for showing us an alternative to _Kit_Deodexage : AutoDeoTool (see below)



ChangeLog of the HOW TO :

Quote:

07/04/2011 :
* Switch bugy sgs2converter.jar to new sgs2toext4.jar from drphrozen
* Re-Add the Convert_sgs2img.exe tool to extract .img to .ext4.img (end of post)
CMD command :

Code:
Convert_sgs2img.exe factoryfs.img factoryfs_ext4.img
07/02/2011 :
Modification of _Kit_deodexage.zip in order to add the custom java.awt.jar from xeudoxus

07/01/2011 :
Add the new version of drphrozen sgs2converter.jar, available HERE
Now you just need to double click on the sgs2converter.jar, without opening any CMD promt command.
You drag and drop your stock .img file and the tool will convert it in <inputname>.ext4.img in the same folder


06/30/2011 :
How to manually deodex Email.apk and MobilePrint.apk : (working for others APKs)

Code:
Quote:

1/ In the same folder, you put :

Quote:

*Email.apk *Email.odex *MobilePrint.apk *Mobileprint.odex AND all the content of the initial ODEXED framework folder (with all JAR files) PLUS custom java.awt.jar AND *smali.jar ---> found in _Kit_Deodexage/_binaires/ *baksmali.jar ---> found in _Kit_Deodexage/_binaires/

2/ Then open a CMD promt in the target folder 3/ Then type :
Code:
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:java.awt.jar: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 Email.odex
You have a new OUT folder created 4/ Then type :
Code:
java -Xmx1024m -jar smali.jar out -o classes.dex
A classes.dex file is created 5/ Open (without extracting) Email.apk with 7-zip Push classes.dex in Email.apk with 7-zip 6/ Put the new deodexed Email.apk in app folder, in _Kit_Deodexage Press Deodex_Gingerbread.cmd You now have a fully deodexed signed zipalligned Email.apk Now Mobileprint.apk : 7/ DELETE classes.dex ans Out folder created before 8/ Same procedure, in CMD pompt, type :
Code:
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:java.awt.jar: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 MobilePrint.odex
You have a new OUT folder created 9/ Then type :
Code:
java -Xmx1024m -jar smali.jar out -o classes.dex
A classes.dex file is created 10/ Open (without extracting) MobilePrint.apk with 7-zip Push classes.dex in MobilePrint.apk with 7-zip 11/ Put the new deodexed MobilePrint.apk in app folder, in _Kit_Deodexage Press Deodex_Gingerbread.cmd You now have a fully deodexed signed zipalligned MobilePrint.apk

Quote:


Important !! You should NOT have error while deodexing

06/27/11 :

added : old version of sgs2converter.jar from drphrozen get it HERE

How To :
Extract sgs2converter.zip to sgs2converter.jar
Put in the same folder : Stock .IMG file, sgs2converter.jar
Open CMD Promt in the folder
run command :
Code:
java -jar sgs2converter.jar factoryfs.img factoryfs.ext4.img
factoryfs.ext4.img is created in same folder. You can pen it with Diskinternals Linux Reader


*AutoDeoTool an alternative to the "kit_deodexage" from HERE thanks to omrij

BONUS :
To personalise your customROM, you can change the name of the ROM shown in Parameters > Version number :

with Notepad++, open the file "\Custom_ROM GS2 by sicOpaT\system\build.prop" and look for the line beginning with : "ro.build.display.id=" (often the 4th). Example : [B]ro.build.display.id=GINGERBREAD.XXKF2
Replace everything after the "=" with what you want. Example : [B]ro.build.display.id=SicOpaT's ROM KF2
Then save the file
Attached Files
File Type: zip Custom_ROM GS2 by SicOpaT.zip - [Click for QR Code] (1.45 MB, 4454 views)
File Type: zip META-INF for updates.zip - [Click for QR Code] (210.2 KB, 2848 views)
File Type: zip Java.awt.jar.zip - [Click for QR Code] (350.9 KB, 2797 views)
File Type: zip sgs2toext4.zip - [Click for QR Code] (20.0 KB, 36160 views)
File Type: zip Convert_sgs2img.zip - [Click for QR Code] (113.6 KB, 5996 views)
File Type: zip _Kit_Deodexage.zip - [Click for QR Code] (4.45 MB, 7785 views)
File Type: zip Custom_ROM GS2 by SicOpaT_v2.zip - [Click for QR Code] (2.61 MB, 3437 views)
File Type: zip smali pour browser.apk.zip - [Click for QR Code] (437.9 KB, 1810 views)
The Following 120 Users Say Thank You to sicopat For This Useful Post: [ View ] Gift sicopat Ad-Free
 
 
20th June 2011, 09:56 PM |#2  
xinfinityoO's Avatar
Senior Member
Flag Wellington
Thanks Meter: 583
 
More
Thanks for the infor .. but what does the " - CWM GS2 Skeleton ROM (wype script) : Custom_ROM GS2 by SicOpaT.zip" do ??

anyway of getting a step by step guide.

Thanks
The Following User Says Thank You to xinfinityoO For This Useful Post: [ View ] Gift xinfinityoO Ad-Free
20th June 2011, 10:14 PM |#3  
Novek's Avatar
Inactive Recognized Developer
Flag T√łnsberg
Thanks Meter: 617
 
Donate to Me
More
I've used Ubuntu until now... Testing this one
20th June 2011, 10:20 PM |#4  
sicopat's Avatar
OP Senior Member
Thanks Meter: 960
 
Donate to Me
More
Quote:
Originally Posted by xinfinityoO

Thanks for the infor .. but what does the " - CWM GS2 Skeleton ROM (wype script) : Custom_ROM GS2 by SicOpaT.zip" do ??

anyway of getting a step by step guide.

Thanks

This is the begining oh a CWM update.zip with the structure folders and I just added : busybox, superuser an su.

I am going to add a step by step guide
The Following 2 Users Say Thank You to sicopat For This Useful Post: [ View ] Gift sicopat Ad-Free
20th June 2011, 10:45 PM |#5  
Senior Member
Thanks Meter: 40
 
More
nice thanks

Email.apk and MobilePrint.apk are leftover. Trying to do them manually but can't find superclass Ljava/awt/componet;
20th June 2011, 11:27 PM |#6  
sicopat's Avatar
OP Senior Member
Thanks Meter: 960
 
Donate to Me
More
Quote:
Originally Posted by Mackzen

nice thanks

Email.apk and MobilePrint.apk are leftover. Trying to do them manually but can't find superclass Ljava/awt/componet;


got the same problem, i took deodexed ones from other deodexedROM
20th June 2011, 11:58 PM |#7  
Senior Member
Thanks Meter: 40
 
More
Couldn't flash using cwm (maybe battery low, don't know)

better luck tomorrow I guess
21st June 2011, 12:29 AM |#8  
NitroOnTheRocks's Avatar
Senior Member
Thanks Meter: 31
 
More
How does the script take care of the Linux file permissions in Windows?
sileshnair
21st June 2011, 01:16 AM |#9  
Guest
Thanks Meter: 0
 
More
Thanks for the info.
HarryRag
21st June 2011, 01:43 AM |#10  
Guest
Thanks Meter: 0
 
More
That was some info which i was looking for the last few weeks, but mostly ended in apps that didn't work for everything.
Gonna give it a shot tomorrow.

Thnx for the info.
21st June 2011, 04:21 AM |#11  
tids2k's Avatar
Senior Member
Flag Sydney
Thanks Meter: 768
 
More
very well defined and this will sure help some newcomers to build thier own custom roms. you deserve a star from me !!
Post Reply Subscribe to Thread

Tags
lli

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes