XDA Recap: This Week In Android (Apr 18 – 25)

Here in the digital XDA newsroom, we spend our days pouring over an average of … more

Sunday Debate: Custom ROMs vs. Modular Tweaks

Join us in a fun Sunday Debate on Mods and ROMs. Come with your opinions and feel free to … more

AOSP 5.1 Lollipop for Nexus Q

Google Nexus Q is an intriguing device released with Android 4.0 Ice Cream Sandwich. It was abandoned by … more

XDA Picks: Best Apps of the Week (Apr 17 – 24)

Apps are at the front and center of any smartphone experience, and with over a … more
Post Reply Subscribe to Thread Email Thread

[Guide/Reference] The Basic APK & Theming Thread... {03/09/14}

25th May 2013, 02:21 PM |#1  
XperienceD's Avatar
OP Senior Member
Flag Here =)
Thanks Meter: 2,505
Hi there.

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:Theming Requirements:
  • Notepad++
  • Photoshop, GIMP or any other image editing software.
  • Patience.
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 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...
adb pull /system/app/ Original_apps
...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...
adb pull /system/framework/ Original_framework
...want to pull your Phones whole system...
adb pull /system/ Name_of_your_Phone
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.

Further Information:
Installing Resources

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...
apktool if framework-res.apk
...and for the second resource apk...

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.
C:\Program Files (x86)\Java\jre6\bin;

Then once you've done that, the command to decompile is...
apktool d framework-res.apk
...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.

Use Linux or a Mac? See the following threads for more information on using apktool on other Operating Systems...


When you've done editing it's time to recompile, using the command...
apktool b -insert folder name-
...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.


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...
java -jar signapk.jar testkey.x509.pem testkey.pk8 framework-res.apk.apk framework-resS.apk
...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.
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...
Originally Posted by AndroidGraphix

- Noobs guide to signing an APK with a Private Key



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...
zipalign -v 4 framework-res.apk ZAframework-res.apk
...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.

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.

Getting APKs Back To Your Phone

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.

GUI Editing

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.

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, 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.


Reading Material
U.I Modding
.9png Editing

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:

Recompiled .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. 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...

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.

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...

...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.
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...

Xposed Framework
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.

- [FRAMEWORK ONLY!] Xposed - ROM modding without modifying APKs

CyanogenMod Theme Chooser
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.


- [GUIDE] HOW TO THEME CM10.1 - Animated Book
Last edited by XperienceD; 3rd September 2014 at 09:51 PM.
The Following 73 Users Say Thank You to XperienceD For This Useful Post: [ View ]
25th May 2013, 02:21 PM |#2  
XperienceD's Avatar
OP Senior Member
Flag Here =)
Thanks Meter: 2,505
ClockworkMod Recovery
Clockwork Mod (CWM)

ClockworkMod Recovery zips are used for flashing individual files to whole ROMS and can be a life saver if you push a badly edited apk to your Phone that results in a bootloop. There's also a few programs that can assist you with that too, but if all you're doing is replacing a few files all you really need is a template, then it's just a matter of creating the Phones folder setup in the zip which is simply creating folders: system\app - system\media\audio etc then dragging and dropping your files into it. A basic understanding of the updater script is essential, a will more than likely wipe your Phone whereas a may just replace files but it might delete some also.[/QUOTE]

See below for a Template but first some helpful links...
This is my which is set up so you can add your own files to the framework and apps folders in the main system location, but you can easily add other folders to it if you want to add things like fonts, tones or anything else, just remember to add folders within folders if that's where the files you want to include are such as tones, media\audio\alarms for example.

If you navigate to META-INF\com\google\android you will find the updater-script which controls how the zip works and the text you see when you run it in CWM. As this zip is just for basically over writing files you don't need to edit anything except for a few lines...

...this is how I've edited it for my Ice Green ResMods theme... just edit it using Notepad++ to your liking.

When adding files to your zip add them using Normal as the Compression Method...
...Remember to remove the text files I've added otherwise they will be flashed to your folders too.

And that's pretty much it, the only way you're really going to learn is by reading then putting into practice what you've read and picking stuff up along the way, fortunately there are numerous guides for numerous mods and tools to help with a variety of tasks.

If you feel something more should be added to this thread please feel free to suggest it.

Credits & Thanks:
And not forgetting @iBotPeaches and @Brut.all for making it possible with - [UTIL][Feb 02 2013] Apktool v1.5.2 - a tool for reverse engineering apk files
Last edited by XperienceD; 19th April 2014 at 11:32 AM.
The Following 22 Users Say Thank You to XperienceD For This Useful Post: [ View ]
25th May 2013, 02:22 PM |#3  
XperienceD's Avatar
OP Senior Member
Flag Here =)
Thanks Meter: 2,505
Random Stuff...

Originally Posted by ttibbetts83

here are some links for ubuntu installs that will help with .apk modding on ubuntu for those who want it

how to setup apktool on ubuntu

ubuntu version of

xaraxtreme looks to be a good program from what i have read but i have not tryed it out yet

gimp is avalable through ubuntu software center and for .xml ubuntu has built in editer software just by right click and open with text editer

Originally Posted by XperienceD

Originally Posted by cickii

can someone please tell me which xml is responsible for the blue / gray colors in the picture below.

Finally sussed it. It's LinearColorBar.smali found at Settings\smali\com\android\settings\applications, search for 0x99cc and -0xff6634 and change them for your own colours...

Originally Posted by XperienceD

Hi all.

Just a short write up as a follow on from THIS thread as this is relatively quite simple.

So you want to change your notification background from the plain dark color to something a bit more your style...

...well all you need to do is decompile your SystemUI.apk and navigate to the values folder and open up your drawables.xml and you should see something like this...

    <item type="drawable" name="notification_number_text_color">#ffffffff</item>
    <item type="drawable" name="notification_item_background_color">#ff111111</item>
    <item type="drawable" name="notification_item_background_color_pressed">#ff257390</item>
    <item type="drawable" name="ticker_background_color">#ff1d1d1d</item>
    <item type="drawable" name="status_bar_background">#ff000000</item>
    <item type="drawable" name="status_bar_recents_background_solid">#e5000000</item>
    <item type="drawable" name="status_bar_recents_app_thumbnail_background">#88000000</item>
    <item type="drawable" name="status_bar_notification_row_background_color">#ff090909</item>
    <item type="drawable" name="notification_header_bg">#ff000000</item>
    <item type="drawable" name="notification_tracking_bg">#e5000000</item>
    <item type="drawable" name="recents_callout_line">#99ffffff</item>
    <item type="drawable" name="notification_item_background_legacy_color">#ffaaaaaa</item>
Simply change these two lines...

<item type="drawable" name="notification_item_background_color">#ff111111</item>
<item type="drawable" name="notification_item_background_color_pressed">#ff257390</item>

<item type="drawable" name="notification_item_background_color">@drawable/status_bar_item_background_normal</item>
<item type="drawable" name="notification_item_background_color_pressed">@drawable/status_bar_item_background_pressed</item>
...then add two .9 png images of the same name, status_bar_item_background_normal and status_bar_item_background_pressed to your drawable-hdpi folder, recompile, zipalign, push to your Phone, done.

Quick Tip: If you can't create a .9 from scratch just edit the first two in drawable_hdpi which in my folder is alert_bar_background_normal.9 and alert_bar_background_pressed.9, just remember not edit over the .9 borders.

Last edited by XperienceD; 8th July 2013 at 07:48 PM.
The Following 12 Users Say Thank You to XperienceD For This Useful Post: [ View ]
25th May 2013, 04:31 PM |#4  
jacknb1ack's Avatar
Flag Yogyakarta
Thanks Meter: 69
Donate to Me
hello XperienceD,

first i want to say thank you, finally i can make some modifiaction of my rom, i am managed to get 3-wa-power on my stock rom, show full option in developer setting, change color and icon, etc (still far from my target though).

for now im trying to make my phone running holo dark themes (default is light), at first it looks fine, background change from light to dark, text black to white.

but now i found some color problem, can you help me locate color setting for this :

Click image for larger version

Name:	Screenshot_2013-05-25-21-35-00.jpg
Views:	854
Size:	12.0 KB
ID:	1990170

Click image for larger version

Name:	Screenshot_2013-05-25-21-40-07.jpg
Views:	904
Size:	25.2 KB
ID:	1990171

Click image for larger version

Name:	Screenshot_2013-05-25-21-40-21.jpg
Views:	825
Size:	21.6 KB
ID:	1990172

Click image for larger version

Name:	Screenshot_2013-05-25-21-41-40.jpg
Views:	803
Size:	23.3 KB
ID:	1990173

and for setting color, i want to change text color to holo_blue

for now, i am doing bruteforce, line per line, hope can fix this tonight, but if anyone know the where should i change the color setting, i am more than happy to accept it

The Following User Says Thank You to jacknb1ack For This Useful Post: [ View ]
26th May 2013, 08:46 AM |#5  
XperienceD's Avatar
OP Senior Member
Flag Here =)
Thanks Meter: 2,505
Originally Posted by jacknb1ack

but now i found some color problem, can you help me locate color setting for this :

Check the links above "where to find colors" and "changing system text".
26th May 2013, 03:01 PM |#6  
jacknb1ack's Avatar
Flag Yogyakarta
Thanks Meter: 69
Donate to Me
great, i think i've clicked all the link in ur post ... but looks like i've missde some link xD ...

thanks again.
18th June 2013, 11:08 PM |#7  
XperienceD's Avatar
OP Senior Member
Flag Here =)
Thanks Meter: 2,505
Originally Posted by jacknb1ack

great, i think i've clicked all the link in ur post ... but looks like i've missde some link xD

Did you find it in the end?
19th June 2013, 05:50 AM |#8  
Junior Member
Flag North Sulawesi
Thanks Meter: 1
Thumbs up
nice tutorial
20th June 2013, 11:27 AM |#9  
jacknb1ack's Avatar
Flag Yogyakarta
Thanks Meter: 69
Donate to Me
Originally Posted by XperienceD

Did you find it in the end?

yes .. thanks to you and all developers and themer here, i can finish my own customizing rom xD

and lately i've found that its need to resign all system apps to do better in what i want, and here is my last work xD
20th June 2013, 05:17 PM |#10  
XperienceD's Avatar
OP Senior Member
Flag Here =)
Thanks Meter: 2,505
Originally Posted by jacknb1ack

yes .. thanks to you and all developers and themer here, i can finish my own customizing rom xD

Nice 1.

Originally Posted by jacknb1ack

Post Reply Subscribe to Thread

apktool, decompile, guide, how to, theme
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes