[Motorola Atrix 2] alteredlikeness:
*THIS HOPES TO SERVE AS A SLIPPERY STEPPING STONE FOR THOSE VENTURING INTO THE MODDING SCENE - AND FOR ANYONE TO POST THEIR QUESTIONS, ANSWERS, REQUESTS, AND COMMENTS ABOUT THEMES/MODS*

NOTE: This is still a WIP... I will clean it up, add/remove/replace as I, and others, see fit. Trying to make this a good resource for those wanting to journey into the rabbit hole..

I will try to make this as general as possible, but it is still mostly based off of Windows 7 OS. I will attempt to incorporate Linux (Ubuntu) as I can. Also, I urge other devs and users to please offer your advice or comments on how to make this thread as useful as possible, "I accept opinions, phone numbers, and the fact that not everyone wants smiles and eye contact" (sorry, homage to doseone - couldn't resist;)) - but PM's or posts are fine...

Finally, I have said it before about Android, and will say it again.. “there is more than one way to skin a cat...” meaning, that there are many, many ways to achieve the same outcome with different methods (but, I’m not sure who would want to skin a cat, and what for… but I guess I don’t even want to know where that phrase came from) - so, PLEASE SEARCH for more information, methods, tricks, and techniques - I can't fit everything under the sun into two posts - plus, I still got a lot to learn myself ;)...

Tools

Java JDK

Android SDK

7-zip (or similar file manager)

Notepad++ (or similar text editor – do not use windows notepad!)

GIMP (or similar image editor)

Sign+ (or similar zip-signing program)

Getting files from your phone

-Root browser: copy from original file location to sdcard

-adb pull (I will not go into an adb tutorial, but here’s an example):

adb pull /system/app/SystemUI.apk C:\Pulled

(I have two folders (“Pulled” and “Push”) in the root of my C:\ drive, where I do all my pulling and pushing)

-Take from a cwm backup (nandroid)

-Make a System Dump through adb (this is just something kind of fun, but not so necessary):

adb shell
su
busybox tar czvf /sdcard/systemdump.tgz /system
exit
exit
adb pull /sdcard/systemdump.tgz

You can delete it from your sdcard once it’s on your computer.

(for a Data Dump, just change the location to /data, and rename the tar file output..)

Edit png/jpeg images

-use 7-zip, winzip, (or stock File Roller on Ubuntu)

-GIMP or Photoshop (work best – but there are many other “tools” out there)

-open the apk (archive) with one of the above mentioned file managers and navigate to the appropriate /res/drawable folder (usually drawable-hdpi, but not only..). And, either copy the files you want to edit directly from there to your desktop or working folder, and make edits and/or drop your replacement files in the appropriate drawable folder in the apk with your file manager. Then move to your system to try it out.

GIMP Notes (it’s what I’m most familiar with, so, Photoshop users use your similar methods):

-Many times the images are in “Indexed” color mode. Go to Image>Mode and change it to RGB mode to avoid editing troubles.

-In GIMP 2.8.0, use the “Export..” feature to save your edited images (in older versions, use “Save as..”), and given quality options, I usually tend to the highest, and all boxes checked.

Decompiling/editing apks

Decompiling apks is necessary to edit .xml files and .9.png files.

See here for more information on the original apktool by brut.all: http://code.google.com/p/android-apktool/ <-- for ICS framework-res.apk, you need to decompile with v1.4.2, and compile with v1.4.3

See here for new version (v1.4.9) of apktool taken over by iBotPeaches: http://xdaforums.com/showthread.php?t=1755243 <-- USE THIS ONE (it works for decompiling AND recompiling framework-res.apk on ICS)

More resources for decompiling/recompiling:

http://xdaforums.com/showthread.php?t=1752201

http://xdaforums.com/showthread.php?t=1466100

Some Tools:

APK Manager/APK Multi-Tool: http://apkmultitool.com/?q=node/5

APK Changer: http://xdaforums.com/showthread.php?t=1189971

Studio Android: http://xdaforums.com/showthread.php?t=1491689

Tickle My Android: http://xdaforums.com/showthread.php?t=1633333

-use apktool alone (see above links for details)

-use an APK editing program (I still mostly use APK Manager v5.0.2 and switch out the apktool files)

-set the proper framework for apktool by placing framework-res.apk, moto-res.apk, blur-res.apk, and SystemUI.apk in the same folder as apktool.jar. Then, open the command prompt or terminal on that folder (need to hold shift and right-click maybe), and type the following, one at a time for each of the four apks listed above, hitting Enter after each entry (note that not all 4 apks are needed for all files, but it doesn’t hurt):

apktool if framework-res.apk

You should get a “Framework installed to:” message after each, showing you the location to which they were saved. Note on that: In all actuality, you could simply drop a copy of each in the \apktool\framework folder (my path is C:\Users\Owner\apktool\framework\), but rename them as following:

framework-res.apk --> 1.apk

moto-res.apk --> 2.apk

blur-res.apk --> 3.apk

SystemUI.apk --> 127.apk

Re-compiling apks

When compiling system apks, the trick is to save the original signatures (META-INF) folder, the AndroidManifest.xml (unless you are editing that but, that’s a whole different story depending on the apk), and not to compress the resources.arsc file (where all of the /values folders get hidden). Some apk tools do some of the work for you, but here’s few methods (they can be dependent on what was edited):

-after re-compiling your apk, copy your edited and compiled files back over to the original apk to preserve signatures and everything else you did not edit (do this with two 7-zip windows open). For edits to any xml in the /values folders, you need to copy over the resources.arsc also (see next note).

-after editing anything in the values folder, you need to re-insert the resources.arsc without compression. For example, rename your SystemUI.apk to SystemUI.zip, take out the newly compiled resources.arsc with your file manager and then “Add to archive..” that resources.arsc to the SystemUI.zip in “Store” mode (or “No compression”). Then rename the .zip back to .apk, and you should be good to go (you can check the compression directly in the 7-zip window – if the “Size” and “Packed size” values are different, then it’s compressed).

-you can also do it vice-versa, and copy the original META-INF, AndroidManifest.xml, etc., to your edited apk with 7-zip

-if you want to edit the AndroidManifest.xml, depending on the specific apk, be prepared to re-sign nearly all system and framework apps

Edit 9patch (.9.png) images

Do some research on what 9patch images are and how they work, but the most important point is to not disturb the 1-pixel black border around the image, unless you want to redraw it. You must decompile in order to edit 9patch images.

-use GIMP or Photoshop

-use draw9patch included in the android-sdk (fool-proof)

-with GIMP you can select the inner area, leaving the 1-pixel border unselected, and edit colors and such that way

-draw9patch is included in the /tools folder in the Android SDK, it only allows you to edit the 1-pixel border and only draws in #000000 (black) color. It will add one pixel to all sides if you are not careful, so you may need to resize it (down 2 pixels) with GIMP first

Baksmali/smali classes.dex (jar/apk files)

You need to have deodexed files to edit the classes.dex and the smali files within. See here for more info, downloads, and the definition of smali, baksmali, and dalvik: http://code.google.com/p/smali/

-decompiling the apk or jar with apktool will also disassemble (for editing) the smali files

-I used to use this baksmali/smali set with tutor (a good resource): http://xdaforums.com/showthread.php?t=1136625

-or, as I typically do now, just remove the classes.dex from the apk/jar and just baksmali, edit, then smali that into a new-classes.dex. For example, I have a folder called smali_bak on my desktop containing baksmali.jar, smali.jar, and a .txt file with the commands shown below (I’m lazy to type it each time, so I copy and paste:)) – I put the classes.dex that I wish to edit in that same folder, then open the command prompt on that folder and type the following:

To disassemble (baksmali):

java -jar baksmali.jar -o classout/ classes.dex

To assemble (smali):

java -Xmx512M -jar smali.jar classout/ -o new-classes.dex

Then, rename it to classes.dex and drop it in the original apk or jar file with a file manager (no need to worry about compression with the classes.dex, as far as I know)

Deodex and create new odex files

Deodexing is basically the process of converting your .odex files into classes.dex files, and inserting those into the apk/jar - basically. And, re-odexing is the opposite - basically.

See cogeary's excellent guide on deodexing for an excellent guide on deodexing.

-xUltimate v2.4+ works well for deodexing

-see also dsixda's Android Kitchen, and there are many other tools for deodexing..

-See here for manual deodex methods: http://xdaforums.com/showthread.php?t=1208320

-See here for a tool/guide to create a new odex file: http://xdaforums.com/showthread.php?t=1853523

This is the new bootclass path for us (and a bunch of other Motos) to use with ICS (taken from /init.rc, minus the jars that didn't exist in /system/framework):

/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

Methods to move your modded files to your phone

-Create cwm recovery flash zips: Create a zip package (normal compression is fine) containing the proper folder structure (for example: /system/app/ and put your apk in the /app folder if that’s where it belongs). I have two folders on my desktop: /system and /META-INF, which I re-use basically for any flashable zip that I make (except ROM’s, of course). The /system folder has an /app folder or /framework folder usually, depending on what I was last working on (but it can obviously have different paths and many folders if need be), and in the /META-INF/com/google/android folder is an updater-script, and an update-binary file (just grab those from another update.zip mod package around here for now). The updater-script has the installation (or removal) info – meaning the location, permissions, and so on… After you create a zip package with those items and your modded files, then use a program like Sign+ to sign the package (or don’t but then you will need to toggle signature checks in recovery mode before installing). This will create three new files in the /META-INF folder (two CERT files and a MANIFEST).

-Use adb to push the files (don’t forget to set proper permissions!):

-Use Root Explorer (or similar) to move it (don’t forget to set proper permissions!):

NOTE:

When experimenting with system files, please have a backup accessible just in case. Or, as I often do, make two zip packages - one with the modded files, and one with the original files to restore if necessary. And, as always, you are responsible for what you do to your device.

FURTHER READING:

Since I am obviously not the first to put something like this together, here are a few other general themeing guides:

Guide by theimpaler747: http://xdaforums.com/showthread.php?t=916814

Guide by Nottach: http://xdaforums.com/showthread.php?t=1186819

Interactive help thread by jeffsanace: http://xdaforums.com/showthread.php?t=1605509

More (possibly out-dated) tips from Stericson: http://xdaforums.com/showthread.php?p=3175518

See also this theming guide - did not read fully through it, but looks promising.