I started this thread to try and simplify the process of modding and theming Android, there are plenty of other guides out there but I wanted to provide something a bit more complete and that covers a bit more than just the decompiling and building an apk. For example, many guides leave out the zipalign process which you'll read below is quite important, so I've tried to write this as something I would have liked to have read when I first started to learn how to theme, which in the long run might just save you a lot of time.
Minimum Requirements:Quick Tips;
- .apk files are applications on your Phone, but when they''re on your computer you can browse them exactly like you would a .zip file, so set your default zip program as the default program for handling apks which will makes things much easier when working with them.
- Download themes for your Phone, for other Phones too even and compare the res folders and screen shots of the theme as that will give you a good idea of what image you need to look for when modding your own apks.
- If all you want to do is change images then you don't even necessarily need to decompile, you can just drag and drop images in to an apk to replace a stock image so long as they have the same file name.
- For more complex mods like changing text colors and layouts (.xml files) and .9 png images then you will have to decompile.
- Download this Apktool_2.9.03.zip which you can extract to a folder and place anywhere you want on your Computer, this is how my current folder looks...
...(I recommend C:\Apktool_2.9.03), then you can run any adb, apktool, zipalign, Baksmali or signing command prompts from it. I've included a Text file with a list of the most common commands you'll need so you can just copy and paste them into the cmd window.
Command Prompt Editing
Using a program is great sometimes you can run into issues if your firmware or the program is updated which may cause a conflict, so if and/or when then does happen you'll know how to do things manually.
Getting APKs To Your PC
You have three options here...
1. Extract them from a ROM zip.
2. ADB. Open a command prompt window in the ADB folder (see below) and type/copy the following command...
3. Use a file manager on your Phone to copy and paste files to your SD, then connect to your PC and use Windows Explorer to copy and paste to your apktool folder....which will pull the whole app folder to your computer and create a new folder called Original_apps, which you can then simply copy apps to the main folder ready to be modified (keep the Original_apps folder as a backup). Then do the same for your framework folder...Code:adb pull /system/app/ Original_apps
...want to pull your Phones whole system...Code:adb pull /system/framework/ Original_framework
Code:adb pull /system/ Name_of_your_Phone
For apktool to work you need to install the resources needed by your apks for de and recompiling, and those resources are other apks, the first apk regardless of your Phones manufacturer is going to be your framework-res.apk. The second apk you need is dependent on the manufacturer so you need to check your framework folder for another apk such as twframework.apk or SemcGenericUXpres.apk. Put those two apks in the Apktool_2.9.03 folder to begin with then open a command prompt window. The easiest way for me is holding the shift key then right clicking the mouse and selecting Open command window here, but if you're not able to do that then click your Start button and search for Command Prompt, then open it. You then need to point it to the relevant folder, so type cd then copy and paste the location of the folder (cd C:\Apktool_2.9.03) and hit enter.
The install commands are...
...and for the second resource apk...Code:apktool if framework-res.apk
Code:apktool if SemcGenericUXpres.apk
If you get any java not found issues you need to set up the PATH for it in your Environment Variables, you can find a short Guide on how to HERE.
This is how mine looks...
...but it should be there after you install Java.
Code:C:\Program Files (x86)\Java\jre6\bin;
Then once you've done that, the command to decompile is...
Use Linux or a Mac? See the following threads for more information on using apktool on other Operating Systems......and so on for each individual apk you want to modify. A new folder will be created that is named after the apk you are modding, then you can edit xmls, smali files and .9png images. You'll notice that there are a lot more folders when you decompile an apk, that's normal as those folders are from the resources.arsc and where you'll find the xml files you may need to edit to make the changes you want.Code:apktool d framework-res.apk
- [WIN/LINUX][Decompile/Compile] Quick Mod Tool 4.0 [decompile and compile with speed]
- APK Manager for Mac OS X
- [Linux][UTILITY][TOOL] APK Multi-Tool
- [tutorial] decompiling,recompiling and signing in linux (27-01-2013)
- How to install and use Apktool with Ubuntu
When you've done editing it's time to recompile, using the command...
...and if you've edited your files correctly then it should compile with no errors and create a folder named dist in the decompiled folder along with a new apk.Code:apktool b -insert folder name-
Before using the new apk you will need to sign it, to do this you need two things from the original apk, the AndroidManifest.xml and META-INF folder, simply open the apk then drag and drop them to the dist folder, and you also need to extract the resources.arsc from the newly built apk so drag and drop that into the dist folder too. Then drag and drop all 3 back into the new apk, in WinRar it will give you the option to choose the compression method, and it's vital that you choose Store because if you don't then you WILL BOOT LOOP after restarting your Phone!
Alternatively you can use the following command...
...notice the extra "S", the output name has to differ from the input name otherwise it will give an error, if done right it will create a new apk called framework-resS.apk, just remember to rename it back to the original before using it on your Phone.Code:java -jar signapk.jar testkey.x509.pem testkey.pk8 framework-res.apk.apk framework-resS.apk
Signing For The Play Store
If you plan on Publishing a Theme or any other app/apk to the Play Store then using the above method to sign your apks just wont work because you need to give it an individual signature that is unique to you, thankfully @AndroidGraphix has written a great guide that will show you how, it's a bit more fidgety than the above method but simple enough to follow...
DISADVANTAGES OF UNALIGNED APKs
Quite understandably, situation would be reserved for unaligned application packages. Resource reading would be slow and memory usage would be on the higher end of the spectrum. It would also depend on how many unaligned applications are present. For example, if less number of applications with an unaligned home application, you’d see slower application launch times. This is the best case scenario. For a worst case scenario, having a number of unaligned applications will result in the system repeatedly starting and killing processes, struggling with lags and huge battery drain.
The command for zipaligning is...
...notice the "ZA", again that can be anything you want so long as it differs from the original name, I use ZA for an obvious reason, and again don't forget to rename it before using on your Phone.Code:zipalign -v 4 framework-res.apk ZAframework-res.apk
And that pretty much covers command prompt editing, I have a few programs setup for different reasons but this is really my preferred method, feels like you have a bit more control over what's going on.
If you're only modifying one apk then it's easier to just use the copy & paste method, just MAKE SURE to change permissions (rw-rw-r) BEFORE overwriting files, but if changing a few then it's quicker to use a Flashable .zip (see below). Most apps should continue to work but you will most likely need to reboot for changes to take effect.
Or you can use adb to push and install them.
If all the above has worked correctly you should now have your modified apk installed with the changes you've made displayed on your Phone.
The following are programs that not only automate the process above but do a whole lot more too, so have a browse and give them a try.
- [TOOL] V4.0.3-xdaAutoTool ALL-Win
- (App) Androidsuite 2013 v117 (01/04/2013) Jelly Bean Support!
- [TOOL]Tickle My Android - DE/RECOMPILE APPS, CHANGE ICONS...AND MORE!!!!
- Apk Manager
- [Windows][UTILITY][TOOL] APK Multi-Tool
- [WIN/LINUX][Decompile/Compile] Quick Mod Tool 4.0 [decompile and compile with speed]
- [TOOL][WINDOWS] ANDROID MULTITOOL
- [Tool]Advanced ApkTool
- [Tool][Win] Better ADB GUI
- [Tool/windows] [ ADW multitool] [for developers and noobs ]
- [TOOL][NoobFriendly]EAIT:Easy Apk Image Themer
- [Utility][Tool][Windows] Baksmali / Smali Manager
Theming & Modifying
This is where the fun begins, once you've got setup to decompile your apks then obviously you're going to want to mod them, so here's a few pointers to clear up what seems like a daunting process to new comers...
You DON'T need to decompile or sign your apks if just changing images!, simply edit and rename your replacement images on you computer, preferably using the same or similar dimensions then drag and drop them back into the right folders in the apk, always using Store as the compression method, but PLEASE NOTE; .9 pngs can be replaced in the same way, but if you want to edit them in Photoshop for example then you need DO need to decompile them.
A few things to note...
- Smali code is real Developer territory, it's Matrix code to me , thankfully there's usually a guide to follow so you can simply copy and paste code without having to fully understand how it works, so don't fret about this.
.9pngs are simply png images with a 1 pixel border. You can edit anything within that border but anything on or over will give errors when building. Unless you're creating an image from scratch then you can leave the border as it is, it's that simple! Sure there's a bit more to .9png editing but you can find a few links below that go into more detail about .9s and how they work.
xmls are relatively simple and edited with Notepad++, much simpler to understand than smali and again, there's usually a guide to be found for most mods you may want to make yourself, but if you're feeling brave you can experiment with it when you have a basic understanding of how it works.
Restoring modified files if you mess up is easier and quicker with a CWM.zip, especially if you're modifying any framework apks! Just because an apk might build with no errors doesn't mean it won't give you any when installed to the Phone.
- Tutorial :- Changing App Icons
- [TUTORIAL]How to Theme Your MMS
- [How-to] Edit the "About Phone" display
- Build Your Own KitKat Theme For Any Device
- How To Colorize Lock Screen Clock in Jellybean
- [Tutorial][VIDEO] Add/integrate apps into Settings app!
- [TUTORIAL] Where to find the colors for making a theme
- [MOD][GUIDE]LockScreen Clock with seconds[ANY ROM]
- [Tutorial]Howto Add Cpu Control & Stats in Settings.apk!
- [TUTORIAL] How to add various framework/Settings mods
- [GUIDE] 4.2 Quick Panel with Lidroid Toggles & Volume Sliders
- [TUT][JB] HOW TO THEME SystemUI.apk for TOTALLY newbie!
- [HOWTO] Integrating/Adding applications to the settings menu
- [TUTORIAL][ICS][GB][JB]How to change Android's black background
- [GUIDE] How to get Transparent App Drawer [Launcher2.apk or Trebuchet.apk]
- [MOD][TUT] Merge The WiFi And Signal Icons
- [MOD] ??? Super Circle Battery with % ??? Version A-P & Z (Custom) ???
- [GUIDE][MOD][SYSTEMUI] How to add 0.00KB/s meter on statusbar GB/ICS/JB
- [TUT] How To Center The Clock On The Statusbar..And Move Other Icons As Well!
- [How-To]Removing Battery Percentage, Adding Toggles,Battery Circles to Statusbar
- [GUIDE][Mods][All Devices]How to add/ Change Clocks to Analog/ Digital with Seconds
- Ultimate Online Theme Kitchen
- [TOOL] Android Drawable Resizer Tool
- [GUIDE] Want to learn how to theme?
- [Guide] demystifying build.prop [Valid entries]
- General Questions about Themes GO HERE!!!!!
- [Collection] ICON SETS | Over *750* different Icon Packs
- [INFO] Custom framework-res.apk resources.arsc using vendor overlays
- [Tutorial][NICS Themer] Create Your Own Themed apk & Become a Themer
I hope after reading this explanation you're left wondering what all the fuss is about, as it really is quite simple. I'll use the following two images, btn_default_pressed_holo.9 & status_bar_close_off.9 to illustrate the basic point of the borders...
Decompiled .9pngs:Those borders control which part of the image is stretched (Left & Top) and where on the image content will be displayed (Right & Bottom). We'll use Draw 9-patch which is for editing the borders of decompiled .9pngs and lets you see how the image, when stretched, will be displayed on the Phone. Notice that the borders are different sizes, well that's because I only want/need a certain part of the image to stretch to get the desired look on the Phone.
You can get away by not using a border but you would need to edit your image to specific dimensions to accommodate for the stretching, for example it might look fine for a simple OK button but it might not look right if you used the same .9png for a screen press which stretches the whole length of the screen, so you're better off just using them to begin with, plus you'll more than likely get errors down the line while decompiling or recompiling your apk.
...in the image below the left side shows the stretched image and desired effect should look on the Phone and the right side shows how it would look if I had edited the borders incorrectly or used none at all...
The use of the border is made even more clear when you add text to an image. For my status_bar_close_off.9 I've filled all four sides of the image (except for an empty pixel in all four corners as that is the max amount of border you can use) as I need it to stretch the image just how I've edited it...
So that's basically it, depending on the image you're editing you can usually leave the borders alone but if you create one from scratch then you might need to play about with them if your images doesn't look quite right when used on the Phone. Here's a few links that will assist you further, especially the batch editing...
...but if I used the same sized left side border as the btn_default_pressed_holo.9 then this is how it would look on the Phone...
...which is obviously not the look I'm trying to achieve, as the left side border is causing the image to stretch incorrectly.
- How to edit .9.pngs
- [TUTO] Create your 9.png !
- [UTILITY][TOOL] 9patchPngSuite [Windows&Linux]
- How to draw NinePatch images with Photoshop - .9.PNG
- [TOOL][Multi-Platform][.9.png][ALL DPIs] Android Resizer Tool
- [Tutorial][Commentary] How To Batch Edit .9PNG/PNG Images
- [tool] 9compiler - batch process for themers android
- [FRAMEWORK ONLY!] Xposed - ROM modding without modifying APKsQuote:Originally Posted by rovo89
In this thread, I'm presenting a framework which gives you the possibility to modify your ROM - without modifying any APK (developers) or flashing (users)!
- No need to modify any APKs. This means:
- No need to decompile, change things in smali, compile, sign, ...
- It will work for odexed and deodexed ROMs.
- Your mod is not bound to a specific version of the ROM. Unless there is a major change in the methods called for a certain functionality, your mod will continue to work even when you upgrade your ROM. Hell, it will probably even work with different ROMs.
- Multiple mods can be installed at the same time, even if they change the same package. So you can use these battery icons and those quick toggles. Even hooking the same method twice is possible. Of course, this only works properly if the mods are not trying to do incompatible things.
- It does its magic at runtime. That means you can implement options to let the user decide if they prefer the bikeshed to be painted in red or blue. Or you can have some extra logic for certain ROMs without building different mod versions.
- It can be disabled easily without having to reflash.
- It's open source.
CyanogenMod Theme Chooser
- [GUIDE] HOW TO THEME CM10.1 - Animated BookQuote:Originally Posted by Annex1
Theme book was created by Annex and Ebs512. I've been asked alot of questions from how to get started? what do I need to get started? to What Graphics program do I use? etc. We made a real simple theme guide to help get you started. This is in Layman Terms.. Nothing fancy.
ONLY THING FANCY IS MY FLASH BOOK
YOU MUST HAVE A FLASH PLAYER INSTALLED TO VIEW THIS!!!
- [Guide] Porting XTheme themes
- [How to] XMLGenerator.jar + batch script v2.0
- [Guide] Xposed Framework/TabletUI (Noob-Friendly)
- [Tool] Drawable XML generator for CM7 theme chooser
- [Guide] How to port themes to T-Mobile Theme Chooser
- [Tool] [Theme Creator] [CM/Avatar] Theme creator tool
- [INDEX][WiP] List of APPs & MODs that use XPOSED Module
- [Tool] nhnt11's XML Generator Revived V2+Extended UPDATED!
- [DEV/GUIDE]Creating APKs for use with TMobile Theme engine
- [Tool][PortCx] Port CM Themes to Xtheme Engine in One Click!
- Theme-Porter [v1.0] [Any Firmware / Rom Compatible] [WINDOWS]
- [GUIDE] T-mobile theme engine for the faint at heart (non-linux users)
- [1/30/2013] Mega 4.2.1 BlackBean Theme Template [XXHDPI/XHDPI/HDPI/TVDPI]
- [MOD][XPOSED][4.0+] XThemeEngine beta5 - Theme engine for any rooted phone
- [APK][Xposed] ResXploit : Theming your android the easiest way! No decompiling APKs!
- -·=»‡«=·-[JB][CM10] Theme Engine Template Updated To V4 [8-7-12][XHDPI/HDPI]-·=»‡«=·-