Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[A] How do I edit services.odex?

OP software_samurai

16th November 2010, 03:02 AM   |  #1  
software_samurai's Avatar
OP Member
Thanks Meter: 46
 
94 posts
Join Date:Joined: Nov 2006
More
I'd like to make a few changes in the services.odex file, and I want to make sure I do it correctly the first time, so I'd like to run this by everyone for comments/corrections.

So far, these are the steps that I *think* are correct:

1. Pull /system/framework/* files onto my PC.
2. On the PC, baksmali the services.odex.
3. Makes the changes to whatever .smali file I wish.
4. Rebuild services.dex via smali (using the output dir created by baksmali).
5. Insert services.dex into services.jar (using, say, WinRAR).
6. Push the new services.jar onto /sdcard and then copy it over to /system/framework dir.
7. Reboot and pray it works.

Is this correct?

---

EDIT: See my reply below for the answer.
Last edited by software_samurai; 23rd November 2010 at 04:52 AM.
18th November 2010, 01:41 PM   |  #2  
software_samurai's Avatar
OP Member
Thanks Meter: 46
 
94 posts
Join Date:Joined: Nov 2006
More
Should I post this question over in the "Captivate Android Development" forum? Anyone?
22nd November 2010, 01:39 PM   |  #3  
ock's Avatar
Senior Member
Thanks Meter: 1,381
 
969 posts
Join Date:Joined: Mar 2010
Small bump for this post, interested in the correct procedure for this too.
23rd November 2010, 04:49 AM   |  #4  
software_samurai's Avatar
OP Member
Thanks Meter: 46
 
94 posts
Join Date:Joined: Nov 2006
More
Cool [A] Here are the steps
Yeah, it took me a week of digging to find this answer.

Disclaimer:

1. Proceed at your own risk and don't blame me if you brick your phone.
2. While I've done my best to document the steps I took, there's always a chance I've mistyped something.
3. If you're unsure at any point, STOP! Re-read everything so you fully understand what you're doing.
4. Editing .odex files can be extremely tricky! All it takes is a bad edit to royally screw up your phone.

This guide assumes:

* you have a Captivate and it's running stock Eclair. (Don't know about other phones or other OSes.)
* you have rooted your phone, and have busybox & Superuser Permissions installed.
* you have adb installed and working on a PC.
* you have baksmali and smali installed and working on a PC (along with Java).
* you have downloaded the utility "dexopt-wrapper". (Do a search - you'll find it.)
* you know what the BOOTCLASSPATH value is for your phone. (Hint: It's in /init.rc)
* you have made a complete backup of your phone! (Yes, if something goes wrong, it's much nicer to be able to restore files from a recent backup than to have to wipe the phone and start from scratch again.)
- I highly recommend you install ROM Manager w/ ClockworkMod. (And don't delete /sdcard/update.zip)

Notations:
When you see a line beginning with >, that's a command to be executed on the PC.
When you see a line beginning with #, that's a command to be executed on the phone.

Ready? Here we go:

put the dexopt-wrapper onto your phone.
> adb push dexopt-wrapper /sdcard

copy all of the /system/framework files onto your PC.
> adb pull /system/framework

let's pretend you want to change something in services.odex.

decompile the .odex file
> baksmali -x services.odex -o services.out

now edit whatever .smali file you want in the services.out folder.

rebuild the classes.dex file for services.odex.
> smali -o classes.dex services.out

now put classes.dex into services.jar (I used WinRAR, but other ZIP utilities should work.)

put the new .jar file onto your phone.
> adb push services.jar /sdcard

> adb shell

become super user
# su

put the dexopt-wrapper utility into the bin folder with the correct permissions. (you only need to do this once, obviously.)
# cd /system/bin
# busybox cp /sdcard/dexopt-wrapper .
# busybox chmod 755 dexopt-wrapper

# cd /sdcard

create a new .odex file from the new .jar file
# dexopt-wrapper services.jar new.odex [BOOTCLASSPATH]
yes, fill in the value of BOOTCLASSPATH, without the []

here's the "special sauce": copy over the "signature" from the current .odex file into the new .odex file. do NOT continue until this command succeeds!
hint: the file size of the new.odex file should not change!
# busybox dd if=/system/framework/services.odex of=new.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

now replace the old .odex file with the new .odex file.
# cd /system/framework
# busybox cp /sdcard/new.odex services.odex
# busybox chmod 644 services.odex

and you're done.
# sync
# reboot

Now, if all goes well, your phone should reboot normally.

However, if something has not gone well, you'll hear the bootup sounds, but the screen will be "stuck" on the first white logo screen. That means the new .odex file was not accepted. What to do? Well, first, (and with all do respect) Don't Panic! Plug in the USB line and issue:

> adb reboot recovery

That should drop you into the recovery. "Apply Updates" and that will get you into ClockworkMod. Then you can restore the /system files from your full backup (the one you did RIGHT BEFORE doing any of this, right?) and be back up and running in just a few minutes. (Yeah, I had to do this many times. It's scary the first time, but you get use to it after a while.)

Good luck!
The Following 28 Users Say Thank You to software_samurai For This Useful Post: [ View ]
16th September 2011, 08:34 AM   |  #5  
Senior Member
Thanks Meter: 785
 
1,567 posts
Join Date:Joined: Dec 2010
Donate to Me
More
Quote:
Originally Posted by software_samurai

Yeah, it took me a week of digging to find this answer.

Disclaimer:

1. Proceed at your own risk and don't blame me if you brick your phone.
2. While I've done my best to document the steps I took, there's always a chance I've mistyped something.
3. If you're unsure at any point, STOP! Re-read everything so you fully understand what you're doing.
4. Editing .odex files can be extremely tricky! All it takes is a bad edit to royally screw up your phone.

This guide assumes:

* you have a Captivate and it's running stock Eclair. (Don't know about other phones or other OSes.)
* you have rooted your phone, and have busybox & Superuser Permissions installed.
* you have adb installed and working on a PC.
* you have baksmali and smali installed and working on a PC (along with Java).
* you have downloaded the utility "dexopt-wrapper". (Do a search - you'll find it.)
* you know what the BOOTCLASSPATH value is for your phone. (Hint: It's in /init.rc)
* you have made a complete backup of your phone! (Yes, if something goes wrong, it's much nicer to be able to restore files from a recent backup than to have to wipe the phone and start from scratch again.)
- I highly recommend you install ROM Manager w/ ClockworkMod. (And don't delete /sdcard/update.zip)

Notations:
When you see a line beginning with >, that's a command to be executed on the PC.
When you see a line beginning with #, that's a command to be executed on the phone.

Ready? Here we go:

put the dexopt-wrapper onto your phone.
> adb push dexopt-wrapper /sdcard

copy all of the /system/framework files onto your PC.
> adb pull /system/framework

let's pretend you want to change something in services.odex.

decompile the .odex file
> baksmali -x services.odex -o services.out

now edit whatever .smali file you want in the services.out folder.

rebuild the classes.dex file for services.odex.
> smali -o classes.dex services.out

now put classes.dex into services.jar (I used WinRAR, but other ZIP utilities should work.)

put the new .jar file onto your phone.
> adb push services.jar /sdcard

> adb shell

become super user
# su

put the dexopt-wrapper utility into the bin folder with the correct permissions. (you only need to do this once, obviously.)
# cd /system/bin
# busybox cp /sdcard/dexopt-wrapper .
# busybox chmod 755 dexopt-wrapper

# cd /sdcard

create a new .odex file from the new .jar file
# dexopt-wrapper services.jar new.odex [BOOTCLASSPATH]
yes, fill in the value of BOOTCLASSPATH, without the []

here's the "special sauce": copy over the "signature" from the current .odex file into the new .odex file. do NOT continue until this command succeeds!
hint: the file size of the new.odex file should not change!
# busybox dd if=/system/framework/services.odex of=new.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

now replace the old .odex file with the new .odex file.
# cd /system/framework
# busybox cp /sdcard/new.odex services.odex
# busybox chmod 644 services.odex

and you're done.
# sync
# reboot

Now, if all goes well, your phone should reboot normally.

However, if something has not gone well, you'll hear the bootup sounds, but the screen will be "stuck" on the first white logo screen. That means the new .odex file was not accepted. What to do? Well, first, (and with all do respect) Don't Panic! Plug in the USB line and issue:

> adb reboot recovery

That should drop you into the recovery. "Apply Updates" and that will get you into ClockworkMod. Then you can restore the /system files from your full backup (the one you did RIGHT BEFORE doing any of this, right?) and be back up and running in just a few minutes. (Yeah, I had to do this many times. It's scary the first time, but you get use to it after a while.)

Good luck!

Thanks, was really useful for me
13th October 2011, 09:54 PM   |  #6  
Perka's Avatar
Senior Member
Thanks Meter: 3,136
 
3,598 posts
Join Date:Joined: Sep 2010
awsome thx
24th December 2011, 10:11 AM   |  #7  
Senior Member
Thanks Meter: 237
 
232 posts
Join Date:Joined: Oct 2011
super thanks for guide
1st January 2012, 07:53 PM   |  #8  
Senior Member
Thanks Meter: 87
 
425 posts
Join Date:Joined: Jul 2010
Donate to Me
More
Strange... all thanks but nothing to add?

I had to install the new Android SDK r16 because of buggy "adb" executable (my fault).
http://developer.android.com/sdk/index.html

Newest version smali/baksmali v1.3.0 has been used.
Helpfull page:
http://code.google.com/p/smali/wiki/DeodexInstructions

Copied whole "/system/framework" to my current working folder (reason in command below).

Code:
baksmali -c /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 -a 10 -x Mms.odex -o Mms.out
Already had to put "BOOTCLASSPATH" in this command with "-c" option, else I would get an error stating. "Error occured while loading boot class path files.".
With new baksmali you have to put in the Android SDK api-level with option "-a" of the current Android OS you're working on. For Gingerbread numbers 10-13 work, but 14 (ICS) doesn't work anymore.
Api levels are stated right at the beginning on each "Android X.X Platform" links on the left side of Android SDK page (mentioned above).

For the most part this guide was perfect, but since a lot has been updated I felt this guide needed a minor update too!
The Following User Says Thank You to yani2000 For This Useful Post: [ View ]
2nd January 2012, 02:54 AM   |  #9  
TRusselo's Avatar
Retired Forum Moderator / Recognized Developer
Flag Edmonton
Thanks Meter: 2,797
 
4,703 posts
Join Date:Joined: Jan 2011
Donate to Me
More
to get quicker answers to non-captivate specific questions (without a week of searching) ask android software questions in the XDA > Android OS > fourms instead of the XDA>Captivate fourms.

the Captivate forums are not a frequent stop for experienced programmers and developers to find and answer these type of questions.
The Following 2 Users Say Thank You to TRusselo For This Useful Post: [ View ]
26th June 2012, 03:56 AM   |  #10  
Junior Member
Thanks Meter: 2
 
20 posts
Join Date:Joined: Nov 2011
Quote:
Originally Posted by software_samurai

Yeah, it took me a week of digging to find this answer.

Disclaimer:

1. Proceed at your own risk and don't blame me if you brick your phone.
2. While I've done my best to document the steps I took, there's always a chance I've mistyped something.
3. If you're unsure at any point, STOP! Re-read everything so you fully understand what you're doing.
4. Editing .odex files can be extremely tricky! All it takes is a bad edit to royally screw up your phone.

This guide assumes:

* you have a Captivate and it's running stock Eclair. (Don't know about other phones or other OSes.)
* you have rooted your phone, and have busybox & Superuser Permissions installed.
* you have adb installed and working on a PC.
* you have baksmali and smali installed and working on a PC (along with Java).
* you have downloaded the utility "dexopt-wrapper". (Do a search - you'll find it.)
* you know what the BOOTCLASSPATH value is for your phone. (Hint: It's in /init.rc)
* you have made a complete backup of your phone! (Yes, if something goes wrong, it's much nicer to be able to restore files from a recent backup than to have to wipe the phone and start from scratch again.)
- I highly recommend you install ROM Manager w/ ClockworkMod. (And don't delete /sdcard/update.zip)

Notations:
When you see a line beginning with >, that's a command to be executed on the PC.
When you see a line beginning with #, that's a command to be executed on the phone.

Ready? Here we go:

put the dexopt-wrapper onto your phone.
> adb push dexopt-wrapper /sdcard

copy all of the /system/framework files onto your PC.
> adb pull /system/framework

let's pretend you want to change something in services.odex.

decompile the .odex file
> baksmali -x services.odex -o services.out

now edit whatever .smali file you want in the services.out folder.

rebuild the classes.dex file for services.odex.
> smali -o classes.dex services.out

now put classes.dex into services.jar (I used WinRAR, but other ZIP utilities should work.)

put the new .jar file onto your phone.
> adb push services.jar /sdcard

> adb shell

become super user
# su

put the dexopt-wrapper utility into the bin folder with the correct permissions. (you only need to do this once, obviously.)
# cd /system/bin
# busybox cp /sdcard/dexopt-wrapper .
# busybox chmod 755 dexopt-wrapper

# cd /sdcard

create a new .odex file from the new .jar file
# dexopt-wrapper services.jar new.odex [BOOTCLASSPATH]
yes, fill in the value of BOOTCLASSPATH, without the []

here's the "special sauce": copy over the "signature" from the current .odex file into the new .odex file. do NOT continue until this command succeeds!
hint: the file size of the new.odex file should not change!
# busybox dd if=/system/framework/services.odex of=new.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

now replace the old .odex file with the new .odex file.
# cd /system/framework
# busybox cp /sdcard/new.odex services.odex
# busybox chmod 644 services.odex

and you're done.
# sync
# reboot

Now, if all goes well, your phone should reboot normally.

However, if something has not gone well, you'll hear the bootup sounds, but the screen will be "stuck" on the first white logo screen. That means the new .odex file was not accepted. What to do? Well, first, (and with all do respect) Don't Panic! Plug in the USB line and issue:

> adb reboot recovery

That should drop you into the recovery. "Apply Updates" and that will get you into ClockworkMod. Then you can restore the /system files from your full backup (the one you did RIGHT BEFORE doing any of this, right?) and be back up and running in just a few minutes. (Yeah, I had to do this many times. It's scary the first time, but you get use to it after a while.)

Good luck!

excuse me, where to find the "dexopt_wrapper"? i can't find it anywhere!
Last edited by mythomasy; 26th June 2012 at 08:05 AM. Reason: modify some errors

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

Advanced Search
Display Modes