[A] How do I edit services.odex?

Search This thread

software_samurai

Senior Member
Nov 18, 2006
109
53
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:
  • Like
Reactions: gunnder-xda

ock

Senior Member
Mar 9, 2010
1,007
1,382
Small bump for this post, interested in the correct procedure for this too. :)
 

software_samurai

Senior Member
Nov 18, 2006
109
53
[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!
 

coldflid

Senior Member
Dec 27, 2010
1,586
782
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
 

yani2000

Senior Member
Jul 23, 2010
460
98
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! :)
 

TRusselo

Inactive Recognized Developer
Jan 20, 2011
4,736
2,931
Edmonton
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.
 

mythomasy

Member
Nov 2, 2011
30
2
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:

XeoNoX

Senior Member
Oct 25, 2010
1,040
789
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!


very well written guide for begginers, all other guides i tried were so confusing. thanks
 

garbb

Senior Member
Jun 25, 2009
52
36
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!

If you backup the original services.odex before you replace it with the modified one then if you get stuck in a bootloop you can just use adb shell commands to copy it back and then do adb reboot. This worked for me anyways. Faster then doing a full restore.
Of course you should still to a backup beforehand.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 30
    [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!
    2
    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! :)
    2
    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.
    1
    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.
    1
    Search with Google. You'll find it that way.