[Guide:] The Definitive APK Modding and Theming Thread...

Search This thread

kermage

Senior Member
Feb 3, 2014
307
189
Iligan City
I Checked out your tool today, it's quite awesome... and the GUI is cool... although it took me like 3 minutes to find out how to start a new project... LOL.. and someone also mentioned that in the project thread... until you hover on the "projects" you won't have a clue that it's clickable... also no batch zip alignment... apart from these two, it's very okay!! [emoji106]

Thanks for checking out and glad you liked it. ;)
And sorry for that 3min waste..haha because for me, I thought the GUI will be scary for first timers seeing lots of buttons to be managed. So, i tend to just let it be in text but with tooltips for information. I did mention that there :cool:
 

nirajbandkar

New member
Dec 28, 2013
2
0
Mumbai
Lock screen making totally differenct

Is there any possibility to make a whole new type of lockscreen
Like If u take Naruto the anime
noramly he should load the rasengan and when we unlock the phone he should throw that rasengan as a unlock effect
If we take sniper man noramlly he shoul point sniper and when we unlock he hsould fire bullet from it
Is it possible?
Then kindly guide me :p
 

mnksngh706

Senior Member
Nov 22, 2013
176
12
Delhi
Unable to make mod apk

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.

66xncx.jpg

Minimum Requirements:
Theming Requirements:
  • Notepad++
  • Photoshop, GIMP or any other image editing software.
  • Patience. :silly:

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

    118d4xt.png

    ...(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.
66xncx.jpg

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...
Code:
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...
Code:
adb pull /system/framework/ Original_framework
...want to pull your Phones whole system...
Code:
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:
66xncx.jpg
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...

Code:
[B]apktool if[/B] framework-res.apk

...and for the second resource apk...

Code:
[B]apktool if[/B] SemcGenericUXpres.apk
66xncx.jpg

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

PATH.png


...but it should be there after you install Java.
Code:
[B]C:\Program Files (x86)\Java\jre6\bin;[/B]

Decompiling

Then once you've done that, the command to decompile is...

Code:
[B]apktool d[/B] 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.

decomp1.png

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

When you've done editing it's time to recompile, using the command...

Code:
[B]apktool b[/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.

build1.png

66xncx.jpg
Signing

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!

Orig_new.png


store.png

Alternatively you can use the following command...

Code:
[B]java -jar signapk.jar testkey.x509.pem testkey.pk8[/B] 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...


66xncx.jpg
Zipaligning



- SOURCE

The command for zipaligning is...

Code:
[B]zipalign -v 4[/B] 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.


66xncx.jpg
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. :)

66xncx.jpg

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.


66xncx.jpg

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 :p, 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.
66xncx.jpg

Links

Reading Material

U.I Modding

Text...

Statusbar...

Misc...

66xncx.jpg
.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:

2ivffib.png
m91yz6.png

Recompiled .9pngs:

34owzyq.png
33ae238.jpg

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.

4tx8up.png

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

25aizyo.png

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

o0ym13.png

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

2m639kz.png

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


66xncx.jpg

Xposed Framework


66xncx.jpg

CyanogenMod Theme Chooser



- [GUIDE] HOW TO THEME CM10.1 - Animated Book


Showing this
 

Attachments

  • Capture.PNG
    Capture.PNG
    90.4 KB · Views: 91

ank_thegreat

Member
Jan 19, 2015
15
2
Yogyakarta
[*].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.

[*]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.

Hi..
I totally newbie in this case, and i want to learn...

I started to mod a 3rd apk file e.g. bbm or whatsapp and try to change the images inside the apk file..
But i failed when i try to install my mod apk on my device..
what should i do, do i miss the step..?

sorry for my bad english
 

SXUsr

Senior Member
Jul 11, 2010
8,149
2,869
Here =)
Hi..
I totally newbie in this case, and i want to learn...

I started to mod a 3rd apk file e.g. bbm or whatsapp and try to change the images inside the apk file..
But i failed when i try to install my mod apk on my device..
what should i do, do i miss the step..?

sorry for my bad english
It's hard to know if People have missed a step when they don't list every step they've made. Generally you replace apps using a root browser, but you need to make sure you give it the right permissions. There is a link in the OP to help with that.
 

ank_thegreat

Member
Jan 19, 2015
15
2
Yogyakarta
It's hard to know if People have missed a step when they don't list every step they've made. Generally you replace apps using a root browser, but you need to make sure you give it the right permissions. There is a link in the OP to help with that.

here the step i do..
1. open the apk file with winrar/7zip
2. replace the image file/.png
3. close winrar/7zip
4. copy to my device
5. install it and "the app not installed"
 

SXUsr

Senior Member
Jul 11, 2010
8,149
2,869
Here =)
Bit late to the party with this so if you are too then get on board now whilst still in its infancy, as this is the future of theming. :good:

BitSyko is a group project mainly consisting of 3 Apps. Layers, Files and RomMate with a view to simplify things that are complicated and give an average user more control over his/her rooted lollipop device.

Let's get the to the main app and straight to the point.


What is Layers?

Layers is basically an app that lets you mainly theme your device by using the internal code in lollipop (RRO).

Just theme? No wait.

You can modify your ROM according to your needs be it the developers or be it the users with basic knowledge.

Use it for ROM Fixes or Use it for Translations it's all your choice.

Tell me more about this? Sure, Why not? Go HERE"​
 

silentscreamz

Member
Nov 22, 2013
30
1
Awesome guide and it is much appreciated especially by us noobs...lol. One thing though, I was trying to find the download for CM10.1 Theme Book because the link goes to goo.im but no download shows up for me. If you still have the download that would be sweet...
 

XxNorikoxX

New member
May 3, 2015
2
0
Hey guys!

I followed the steps and everything works, besids the last step, where I need to sign the app.

I copied the META-INF and AndroidManifest.xml out of the original apk into a folder, copied the resources.arsc file out of the modified apk and put everything back to the modified apk. But when I want to install the app on my phone I get an error "App not installed."

Is there a way to sign the app with the "original" key? Because when I the signapk tool for example I need to uninstall the old, non modified app from my phone and install the modified one. But when I want to mod a game I don't want to lose my gamefiles :/

Is there a way to install a modified app without uninstalling the orignal one?
 

Topsy Krett

Senior Member
Jan 2, 2013
54
11
www.priteshtupe.com
Need Help

Hello,

Nice Thread, lots of good information.

Anyway, I'm getting this error :

Exception in thread "main" brut.androlib.AndrolibException: Could not decode ars
c file
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:54)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:40)
at brut.androlib.res.AndrolibResources.installFramework(AndrolibResource
s.java:675)
at brut.androlib.Androlib.installFramework(Androlib.java:641)
at brut.apktool.Main.cmdInstallFramework(Main.java:252)
at brut.apktool.Main.main(Main.java:91)
Caused by: java.io.IOException: Expected: 0x001c0001, got: 0x00000000
at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:48)
at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:43)
at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:95
)
at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:81)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
... 5 more
When, i try ' apktool if framework-res.apk ' command.

I'm using Note 4 SM-N910G on Emotion Rom.

Windows version 8.1, java set up.

PS: i'm not much experienced, in fact, this my first read on anything android :p So, an explanation might help.

Thank you. Cheers.
 

Thebear j koss

Senior Member
  • Oct 24, 2012
    12,326
    21,033
    NYC
    www.designrifts.com
    Hello,

    Nice Thread, lots of good information.

    Anyway, I'm getting this error :

    Exception in thread "main" brut.androlib.AndrolibException: Could not decode ars
    c file
    at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:54)
    at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:40)
    at brut.androlib.res.AndrolibResources.installFramework(AndrolibResource
    s.java:675)
    at brut.androlib.Androlib.installFramework(Androlib.java:641)
    at brut.apktool.Main.cmdInstallFramework(Main.java:252)
    at brut.apktool.Main.main(Main.java:91)
    Caused by: java.io.IOException: Expected: 0x001c0001, got: 0x00000000
    at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:48)
    at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:43)
    at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:95
    )
    at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:81)
    at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
    ... 5 more
    When, i try ' apktool if framework-res.apk ' command.

    I'm using Note 4 SM-N910G on Emotion Rom.

    Windows version 8.1, java set up.

    PS: i'm not much experienced, in fact, this my first read on anything android [emoji14] So, an explanation might help.

    Thank you. Cheers.
    You need to update your apktool.

    LEGALIZE IT.
    Mattias Duarte ruined android. Material design sucks.
     
    • Like
    Reactions: davidwilson83

    Top Liked Posts

    • There are no posts matching your filters.
    • 87
      • First of all, you don't actually need to be a "developer" as such to be able to theme and you don't need to know or have to learn lots of code either.
      • Secondly, EVERYTHING you need to know and need to use to modify an .apk is in this thread!
      66xncx.jpg
      The greatest thing about Android is that you can change just about every element of the U.I and it’s really easy to do too. I wrote this guide to share the experience and knowledge I've gained since joining xda to debrand my SonyEricsson XPERIA X10i that was running Gingerbread. In 2017 there are a few different ways you can theme a ROM.
      1. Apktool, which can decompile an .apk allowing you to modify your own .xmls and .9png images, which is what this thread will focus on.
      2. RRO, Xposed essentially overlay themes or mods.
      There is a variety of programs that use a GUI to do the work of Apktool for you, some good, some bad but at the end of the day they all ultimately do what you can easily do yourself in a faster, cleaner and more efficient manner in my opinion.
      Overlaying doesn't cover every element so falls short of a one stop solution for being able to fully theme a ROM and is a bit more complex and/or restrictive in it's approach.

      66xncx.jpg
      Tools you're going to need:
      • Java - Do this first if you don't have it installed already.
      • Apktool - The main tool for decompiling and recompiling apks.
      • Notepad++ - An essential program for xml editing!
      • Photoshop or Gimp - You'll need one of these for image editing.
      • 7-Zip or WinRar - Required for working with apks.

      We also need the ADB files from the SDK Platform and a sign.jar but to simplify this as much as possible I've made a zip for you to download which contains Apktool and everything else you need that you haven't got from the list above.

      Download APKTool_2.2.4.zip to a location of your choice, preferably the C:\ drive which will give you a folder to work from. To keep the folder updated you can download the updated files from the retrospective thread/sites and simply replace them in the folder.

      66xncx.jpg
      This thread will cover the following in an easy to follow and straight forward manner that will have you theming your own apks in no time.
      • Getting apks from a ROM
      • Deodexing
      • .apk De-compiling
      • .apk Recompiling
      • .apk Signing
      • .apk Zipaligning
      • Pushing Files to your Phone
      • .9 images
      • Vector Drawable
      • .xmls
      • +More

      66xncx.jpg
      Quick Tips;
      • .apk files can be browsed like .zip files so set your zip program as the default for handling apks which will makes things much easier.
      • If all you want to do is edit images then you don't 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.
      • Restoring files if you mess up is easier and quicker with a CWM.zip, especially if you're modifying 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.

      66xncx.jpg
      • Getting apks from a ROM:
      Once your Apktool folder is setup you need to get the apks you want to theme out of a ROM or off of your Phone and there are a couple of ways to do this.

      1. The simplest method is to extract your phones whole system from an unofficial update file from xda, whatever format that may be in depends on your device. I extract the whole system with every new update before doing anything because it gives me a backup of stock files which I can also copy and deodex to be themed.

      2. Use adb commands to pull files to your computer, to do that we need to open a command prompt window (hold the shift key then right click your mouse in the Apktool folder and select "open command window here").

      The command to pull your whole system is...
      Code:
      [B]adb pull /system/ XC_206[/B]
      ...you can choose something other than XC_206 as your folder name but it will create that folder in your Apktool folder. Alternatively, you can just download individual folders and the commands to do that are…
      Code:
      [B]adb pull /system/app/ XC_206 app
      adb pull /system/priv-app/ XC_206 priv-app
      adb pull /system/framework/ XC_206 framework[/B]
      ...or to pull individual files...
      Code:
      [B]adb pull /system/framework/framework-res.apk[/B]

      3. Use a root explorer on your phone to copy files to your SD and then to your PC.​

      Depending on your method you should now have a ApkTool_2.2.4 folder with another folder named 206_system for example in it. The only folders we need at this point are app, priv-app and framework which we need for the next step.

      66xncx.jpg
      • Deodexing:
      “Deodexing is basically repackaging of these APKs in a certain way, such that they are reassembled into classes.dex files. By doing that, all pieces of an application package are put together back in one place, thus eliminating the worry of a modified APK conflicting with some separate odexed parts.”What Is Odex And Deodex In Android
      The tool I use is this - [Tool/Utility] JoelDroid Lollipop Batch Deodexer. To save a lot of time I only deodex the apps I'm going to use because it removes the process of having to mess about with smali and baksmali, plus YOU DON'T NEED TO DEODEX YOUR WHOLE FW!, depending on the apk and/or the mod you want to make you don't even need to deodex.

      So now you should have a folder named system full of deodexed apks that are ready for playing with.

      66xncx.jpg
      • Decompiling:
      Decompiling is the process of deconstructing an apk which gives us workable source code so to speak and we need to do this to be able to edit xmls in Notepad++ or .9 images in an image editor. As said above if you don't want or need to decompile because you just want to change an image here or there you can just drag and drop your res folder out of the apk, find the image I wanted to replace or modify, drag and drop it back in to the apk and push it back to your phone.

      Before proceeding you need to install your framework-res.apk and depending on your FW possibly another apk if there is one in the framework folder, which will put one (or two) apks at C:\Users\your-pc-name\AppData\Local\apktool\framework The two commands to install your apks are...
      Code:
      [b]apktool if framework-res.apk
      apktool if SemcGenericUxpRes.apk[/b]

      The command for decompiling always begins the same, apktool d then simply change it for the name of the next apk you want to modify. To decompile the framework-res.apk the command is...
      Code:
      [B][U]apktool[/U] [U]d[/U][/B] framework-res.apk
      ...this will create a folder named framework-res and it’s at this stage that you can now begin to modify .9 images and xmls to create the desired look or mod you’re after. In this folder you'll find a couple of folders but the one we want is the res folder. First glance of a decompiled res folder can be overwhelming, 1541 folders in my framework but we only need to focus on a handful and it's generally the same in every apk...
      • drawable
      • drawable-xhdpi-v4 (depending on your device)
      • layout
      • values
      ...you may need to delve into others sometimes but it's very rare that I've had to.
      Quick Tip;
      • Once you've entered a few commands so long as you leave the cmd window open you can quickly scroll back through them using your arrow keys.

      66xncx.jpg
      • Recompiling:
      Once you've finished making your mods you need to recompile your apk using the following command...
      Code:
      [B][U]apktool[/U] [U]b[/U][/B] framework-res
      ...notice you only use the folder name here. If you get any errors here due to a bad edit apktool will usually tell you, in a roundabout way, you just need to read the code it throws up then retrace your steps, correct any bad edit and try again. If all goes smoothly you'll now have a new folder called dist, which contains your newly modified apk, but you can't use that just yet.

      66xncx.jpg
      • Signing:
      To sign stock system .apks we need to extract from the original apk the Android.Manifest.xml and META-INF folder, into the dist folder, then from the new apk extract the resources.arsc also into the dist folder, then drag and drop all three files back into the new apk, but NOTE, it's important that you choose store as the compression method, any other will break the apk, and if you replace a broken framework-res.apk you will BOOTLOOP!. And signing is as simple as that.

      For 3rd party apps you can use the following command...
      Code:
      [B]java -jar signapk.jar testkey.x509.pem testkey.pk8[/B] Chrome.apk ChromeS.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 ChromeS.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...

      66xncx.jpg
      • Zipaligning:
      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. - SOURCE
      Move your new signed apk into your APKTool folder, you can overwrite your original if you want, and use the following command...
      Code:
      [B][U]zipalign -f -v 4[/U][/B] framework-res.apk ZAframework-res.apk
      ...notice the ZA, zipaligning creates a new apk which has to be named different from the original, but use what you want, it'll need renaming back to the original again before you use it.

      66xncx.jpg
      • Pushing Files to your Phone:
      So now we need to transfer your apk back to your Phone, you can do it by copying to your SD, then to your system, change permissions, then copy to the right folder, but that's not only time consuming but highly tedious too, so a simpler method is to use adb using the push command as this allows us to push to the SD Card then install it to the system overwriting the original with the correct permissions too. If you do this with the framework-res or SystemUI apks you will need to reboot but generally all other apps will just refresh with the changes applied. The command to push to the SD Card is...
      Code:
      [b]adb push SystemUI.apk /sdcard/SystemUI.apk
      [/b]​
      ...then we need to mount the system before we can install our modified apk and the commands for that are...
      Code:
      [b]adb shell
      [/b]​
      Code:
      [b]su
      [/b]​
      The prefix will then change to the $ sign
      Code:
      [b]mount -o rw,remount /system
      [/b]​
      ...then to install your apk...
      Code:
      [b]dd if=/sdcard/SystemUI.apk of=/system/priv-app/SystemUI/SystemUI.apk
      [/b]​
      If any of that fails you could try an unsecure kernel and/or Chainfires adbd Insecure app. Try the app first but if you still can't mount and push files read this thread - [HOW TO]Make your favorite kernel adbd insecure to run ADB as root on /system and try again.

      66xncx.jpg
      • .9 pngs:
      I hope after reading this explanation you're not still 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:

      2ivffib.png
      m91yz6.png

      Recompiled .9pngs:

      34owzyq.png
      33ae238.jpg

      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.

      4tx8up.png

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

      25aizyo.png

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

      o0ym13.png

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

      2m639kz.png

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


      66xncx.jpg
      • Vector Drawable:

      A VectorDrawable is a vector graphic defined in an XML file as a set of points, lines, and curves along with its associated color information. The major advantage of using a vector drawable is image scalability. It can be scaled without loss of display quality, which means the same file is resized for different screen densities without loss of image quality. This results in smaller APK files and less developer maintenance. You can also use vector images for animation by using multiple XML files instead of multiple images for each display resolution.​
      - developer.android.com/guide/topics/graphics/vector-drawable-resources

      Vector drawables obviously serve a purpose but are a pita imo for themers as they are a lot more difficult to edit and achieve the look you want.

      Using my power menu to illustrate the issue, Power off, Restart and Take screenshot icons are vector drawables but the Record screen icon is a png...
      ftinx4.jpg
      ...as you can see the Record screen icon is significantly bigger and ruins the look of my power menu, to over come this I have two options.

      1. Learn how to edit vector drawables and create a new icon.
      2. Replace the vector drawables and use pngs.

      The latter to me is preferable because I already have images that I've been using for the last few years and want to continue using, to do so I need to replace the code in the relevant xmls to point at images...

      framework-res/drawable/ic_lock_power_off.xml

      Vector drawable code...
      Code:
      <?xml version="1.0" encoding="utf-8"?>
      <vector android:tint="?colorControlNormal" android:height="24.0dip" android:width="24.0dip" android:viewportWidth="24.0" android:viewportHeight="24.0"
        xmlns:android="http://schemas.android.com/apk/res/android">
          <path android:fillColor="#ff000000" android:pathData="M13.0,3.0l-2.0,0.0l0.0,10.0l2.0,0.0L13.0,3.0zm4.83,2.17l-1.42,1.42C17.99,7.86 19.0,9.81 19.0,12.0c0.0,3.87 -3.13,7.0 -7.0,7.0s-7.0,-3.13 -7.0,-7.0c0.0,-2.19 1.01,-4.14 2.58,-5.42L6.17,5.17C4.23,6.82 3.0,9.26 3.0,12.0c0.0,4.97 4.03,9.0 9.0,9.0s9.0,-4.03 9.0,-9.0c0.0,-2.74 -1.23,-5.18 -3.17,-6.83z" />
      </vector>
      My edited code...
      Code:
      <?xml version="1.0" encoding="utf-8"?>
      <bitmap android:src="@drawable/ic_lock_power_off_alpha"
        xmlns:android="http://schemas.android.com/apk/res/android" />
      framework-res/drawable/ic_restart.xml

      Vector drawable code...
      Code:
      <?xml version="1.0" encoding="utf-8"?>
      <vector android:tint="?colorControlNormal" android:height="24.0dip" android:width="24.0dip" android:viewportWidth="24.0" android:viewportHeight="24.0"
        xmlns:android="http://schemas.android.com/apk/res/android">
          <path android:fillColor="#ff000000" android:pathData="M12.0,4.0L12.0,1.0L8.0,5.0l4.0,4.0L12.0,6.0c3.9,0.0 7.0,3.1 7.0,7.0c0.0,3.9 -3.1,7.0 -7.0,7.0l0.0,2.0c5.0,0.0 9.0,-4.0 9.0,-9.0C21.0,8.0 17.0,4.0 12.0,4.0z" />
          <path android:fillColor="#ff000000" android:pathData="M5.0,12.9C5.0,11.0 5.8,9.2 7.2,7.9L5.8,6.4C4.0,8.1 3.0,10.5 3.0,12.9c0.0,4.0 2.7,7.6 6.5,8.7l0.5,-1.9C7.1,18.8 5.0,16.1 5.0,12.9z" />
      </vector>
      My edited code...
      Code:
      <?xml version="1.0" encoding="utf-8"?>
      <bitmap android:src="@drawable/ic_lock_restart"
        xmlns:android="http://schemas.android.com/apk/res/android" />
      framework-res/drawable/ic_semc_ic_dialog_screenshot.xml

      Vector drawable code...
      Code:
      <?xml version="1.0" encoding="utf-8"?>
      <vector android:height="24.0dip" android:width="24.0dip" android:viewportWidth="24.0" android:viewportHeight="24.0"
        xmlns:android="http://schemas.android.com/apk/res/android">
          <path android:fillColor="#8a000000" android:pathData="M5,5l4,0l0,-2l-4,0l-2,0l0,2l0,4l2,0l0,-4z" />
          <path android:fillColor="#8a000000" android:pathData="M19,3l-4,0l0,2l4,0l0,4l2,0l0,-4l0,-2l-2,0z" />
          <path android:fillColor="#8a000000" android:pathData="M5,15l-2,0l0,4l0,2l2,0l4,0l0,-2l-4,0l0,-4z" />
          <path android:fillColor="#8a000000" android:pathData="M19,19l-4,0l0,2l4,0l2,0l0,-2l0,-4l-2,0l0,4z" />
          <path android:fillColor="#8a000000" android:pathData="M16,13l0,-2l-3,0l0,-3l-2,0l0,3l-3,0l0,2l3,0l0,3l2,0l0,-3l3,0z" />
      </vector>
      My edited code...
      Code:
      <?xml version="1.0" encoding="utf-8"?>
      <bitmap android:src="@drawable/semc_ic_dialog_screenshot"
        xmlns:android="http://schemas.android.com/apk/res/android" />
      ...and the result as you can see here provides a much more unified look...
      oqefpc.jpg
      ...and finally my desired end result...
      24exjzo.jpg

      66xncx.jpg
      • .xmls:
      Modifying .xmls is easy and pretty simply to understand, a massive clue in finding the ones you need to edit is the file names. You're not going to find a better guide than the one by Ticklefish so I'll just post a snippet here and you can head over and give the main thread a read and and a thanks.

      XML 101 - XML Modding Made Easy!

      If you're modding Android, eventually you're going to have to edit some XML.
      Want to center the clock in your statusbar? Rearrange the icons in your navbar? Change the layout of your notification screen? Get rid of a carrier label? Change the colour of some text?
      Then you need to edit some XML files.
      And you might not have any idea how...
      Well, don't worry. The purpose of this thread is to show you just easy XML-editing can be. Once you've read it, you'll be one step closer to being an XML expert!
      This guide is meant for noobs, experienced modders and everyone in between. Hopefully everybody can learn something..

      Here's what this thread has to offer so far:

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

      66xncx.jpg
      The following programs are some of the better programs you can use to automate Apktool for you...
      ...there are many others but these are a couple of what I've tried, still use or are popular on xda.

      Quick Tip; Use VTS to edit certain xmls because it gives you a preview of any hex colour code and has a built in editor too which makes finding and changing colours a breeze.

      cixrm.jpg

      66xncx.jpg

      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. I've posted a few links to different tutorials in the next post that you can use as a reference to theme your own phone, while the versions of Android change the methods and code are pretty consistent but you will have to adapt from time to time, but that's how you learn, refine your skills and become able to pass on your knowledge back to the xda community in the form of guides themes and mods.


      66xncx.jpg
      Notable credits and thanks to @iBotPeaches, @Brut.all, @jairomeo, @manup456, @armyranger251, @Stericson, @brandenk, @beagz
      26
      • ClockworkMod Recovery:
      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 ROM.zip will more than likely wipe your Phone whereas a Theme.zip may just replace files but it might delete some also.​


      In the Apktool_2.4.4.zip is my CWM_backup.zip 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. When adding files to your zip add them using Normal as the Compression Method and remember to remove any example files I've added otherwise they will be flashed to your phone too.

      66xncx.jpg
      • Links:
      The following liks are what I've bookmarked over the years and posted them here for you to use as a reference, some of these may not apply for your device directly but that doesn't mean you can't learn from or adapt them to.

      13
      66xncx.jpg
      • Xposed:
      Advantages:

      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. Many modules work for a wide range of ROMs from different vendors.
      • Multiple mods can be installed at the same time, even if they modify the same app. 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.
      - Xposed

      5
      Just added a little section on Deodexing, is it enough do you guys think or does it need more?...

      Deodexing...

      The differences between Odex and Deodex Files...

      In Android file system, applications come in packages with the extension .apk. These application packages, or APKs contain certain .odex files whose supposed function is to save space The odexed file structure works well as an optimization tool. Since these .odex files contain preliminary load information about each system app, the OS knows what to expect when it’s booting up, and consequently, loads all these apps faster.
      On the other hand, it also makes hacking those applications difficult because a part of the coding has already been extracted to another location before execution.

      For instance, on a non-rooted device you’ll find
      system/app/Phone.apk ===> as well as ===> system/app/Phone.odex

      - [GUIDE] - The differences between Odex and Deodex Files


      [TOOL][WINDOWS]Universal Deodexer[ALL DEVICES!!]

      Hi everyone,

      Alokbina and I have created a tool which allows users to very easily deodex apks from a rom. This tool is very useful for Rom developers too.:) For now only windows is supported but we will try our best to make the same tool for linux too and make the tool as user friendly as possible. And, please don't forget to thank alokbina too.

      Requirements:-
      --->Java installed on your PC
      --->system/framework folder from your rom
      --->apks from that SAME ROM with the respective .odex file
      --->Patience and a calm head (common sense included)


      You can watch this video for setting up and using the tool -

      - [FIXED][UPDATE - V3][TOOL][WINDOWS]Universal Deodexer[ALL DEVICES!!]

      3
      Sorry that I ask too many questions..
      What if say I edited a user-app and now want to push it in system/app, should I sign it?

      Asking questions are totally fine. :good:
      Always a pleasure to help. :angel:
    Our Apps
    Get our official app!
    The best way to access XDA on your phone
    Nav Gestures
    Add swipe gestures to any Android
    One Handed Mode
    Eases uses one hand with your phone