[Motorola Atrix 2] alteredlikeness:
WHAT IS THIS, AND WHAT IS IT FOR?

This is a guide for creating a new odex file from a deodexed file, one at a time – manually, or with the tool provided. There are tools/methods for doing the entire system at once, but I have not had any luck with those. Plus, typically, one does not need the entire system re-odexed. This is more for those who want to personally mod their stock odexed systems, or create an odexed ROM maybe.

For starters, you can get away with modding a lot on an odexed system, without needing to deodex. You really only need to deodex in order to edit the smali files within the classes.dex (which is required to achieve the cooler mods). See cogeary’s great guide for deodexing tips.

-------------------------

SCRIPT METHOD (using the 1by1_ReOdexer):

I made this script to speed up the process a little bit (thanks! to jimbridgman and cogeary for their input).

NOTE

: This could hurt your phone if you don't place your original files (the ones that are currently running on your odexed system) in the 'orig-odexed' folder…

Requirements:

Windows OS (for now – Linux coming soon)

odexed system

root

busybox installed

DOWNLOAD the 1by1_ReOdexer_v2.0.zip for Windows

Unzip it on your desktop or other convenient place (with no spaces in the file path), and read the README.txt.

NOTES

-It will show a few failed processes right when the script starts - it's just trying to clean stuff that isn't there..

-This will not push the new modded files to your phone - but, the re-odex process needs to take place in the /system, so this script does a quick switcheroo by pushing the deodexed file to your running odexed system, then replaces the originals (that's why you must place copies of the odexed ones from your system to the 'orig-odexed' folder - I plan on automating that too eventually) - that's also why you may need to reboot afterwards to straighten things out

-It still needs A LOT of work... but it does the job

MAJOR NOTE:

The script is currently set up based on Motorola’s ICS bootclasspath.

To change the file name/path and/or the bootclasspath, right-click on the .bat file and open with a text editor (preferably something like Notepad++) and edit accordingly. The bootclasspath was taken from /init.rc.

-------------

MANUAL METHOD:

I will use the services.jar in this example. Just change the file name and path to existing .odex accordingly for other files. (thanks! to jhotmann for helping me to nail down this method)

Requirements:

odexed system

root

adb

busybox installed

dexopt-wrapper

Put this dexopt-wrapper file in /system/bin with 775 permissions:

X X X

X....X

X....X

Put the deodexed services.jar (or other jar/apk file you want to make a new odex of) on the root your /sdcard (on some phones that means internal storage).

Make sure USB Debugging is enabled.

Put your USB connection to MTP or PTP mode.

The bootclasspath is located in the /init.rc file at the root of your phone. Just make sure that all jars listed in init.rc are actually in your /system/framework folder and only include those in your bootclasspath in the command below. The one from Moto A2/Razr/other ICS is used below (minus the extra jar paths). To replace it with that of a different device, change the word bootclasspath with yours, using the path style as shown in the example below: dexopt-wrapper services.jar new.odex bootclasspath...

Connect with adb (do a adb devices check to make sure you're all good).

To create the new odex, enter the following one line at a time:

adb shell
su
cd /sdcard/
dexopt-wrapper services.jar new.odex /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework-ext.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar:/system/framework/com.motorola.frameworks.core.addon.jar

To copy the signature from the existing odex (change path to /system/app/.. if necessary):

busybox dd if=/system/framework/services.odex of=new.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

Done! Rename new.odex (created on your /sdcard) to services.odex since that is your new signed odex file... and move to your phone using the method of your choice.

---------------------

CHANGE LOG:

11/7/12 (v2.0)
-more automated
-changed the location where the new odex is made
-thanks to [URL="http://forums.acsyndicate.net/showthread.php?113-Re-Odexing-script&p=1369&viewfull=1#post1369"]tanimn[/URL] for the hint
-thanks to [URL="http://xdaforums.com/showthread.php?t=1879128"]alkhafaf[/URL] for his bat files that I got ideas from (his script didn't work for me)

8/25/12 (v1.0)
-initial release
Thanks to the following for testing!:
-A2Trip (formerly DX2Trip) on the A2 ICS
-RETIEF on the RAZR Maxx ICS
-iwabashu on the RAZR ICS
(I tested it on GB - but I am not high-fiving myself :D)

-----------------

Some vague notes on what to do next:

Depending on what you are after by re-odexing, there are different routes. For example, if you only edited or copied smali files, then you only need the new.odex file. Meaning that all of the smali code was inside of that classes.dex of the deodexed file on your sdcard, and you just made that into a new odex file (and copied the signatures from the existing .odex in /system).

If you have a deodexed apk with more edits than just smali (you could really just copy those edits over to your existing odexed apk with 7-zip or similar), but – if you want to, you will need to remove the classes.dex from the deodexed apk, and make sure that the signatures (/META-INF folder) and AndroidManifest.xml are the same as your existing apk (check, and or copy with 7-zip or similar).

.

.

.