Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,810,194 Members 51,720 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE]Ultimate Guide[Decompiling][9 pngs][Theming]

Tip us?
 
iamareebjamal
Old
(Last edited by iamareebjamal; 16th June 2013 at 02:52 PM.)
#1  
iamareebjamal's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 4,701
Posts: 3,604
Join Date: Aug 2012
Location: Batcave
Default [GUIDE]Ultimate Guide[Decompiling][9 pngs][Theming]

The Ultimate Guide

Preliminary Requirements:-

PC with Windows(Please avoid Windows Vista)
Java JRE or JDK
APK Multitool
framework-res.apk, SystemUI.apk, twframework-res.apk, com.htc.resources for installing
7-zip
Notepad++
Android Device for testing
Photoshop or equivalent image editing software
android-sdk(for 9 png editing)
Lots and lots of patience and mind


What this guide includes:-

Main Part:
1. Easiest Decompiling and Recompiling Guide *Must Read before continuing*
Theming Part:
2. APK png resources(General Location of General pngs)
3. Explanation of 9 pngs and how to edit or make them
4. How to Batch edit pngs (Not 9 pngs) (Changing color, etc)



All of us like if all things are present in one guide
This guide covers topics like decompiling, 9 png editing, theming in a very newbie friendly manner.

I have worked upon this guide to make it so that no problem arises during performing certain tasks which I faced.
I have covered workarounds such that they ensure LEAST no. of errors while performing these tasks.

However, if even then any problem arises, I am always there to help you out





Main Part:

Decompiling: [MUST READ]


 

We are assuming that you have installed JAVA, Android SDK and apk-multitool without any problems

1. Copy your mobile's framework-res.apk, SystemUI.apk and twframework-res.apk in others folder in directory where you have extracted apk-multiool
2. Open Setup.bat. Choose 2 :- Installing Framework-res


Setup.bat

Choose 1 (framework-res.apk)
Choose 2 (twframework-res.apk) [similarly install OEM specific files such as com.htc.resources , etc]
Choose 4 (SystemUI.apk)

Window will close each time you choose an option
You will have to restart Setup.bat each time

3. Now place the apk you want to edit in place-apk-here-for-modding

4. Now open script.bat. (If you see any error, either you haven't installed JAVA and SDK[adb] or they aren't implented, Please install them properly before continuing). Click any key to continue


APK-Multitool Window

5. You will see the above window. Now, make sure you have installed all frameworks and Compression level is set to 9.

6. Now, we will choose our project. Click 24. A list of files present in place-apk-here-for-modding will be in front of you. Choose any file

7. Click on 9. Now decompiling will be in process.

8. After it is complete, go to projects folder, you will see a folder with the name of apk you decompiled


Decompiled apk example

If it is decompiled properly, then there will be apktool.yml file in it

9. Do your modifications. Now, you can edit .9.png files (they will be discussed later) and xml files which were uneditable first

You will notice that there will be many new folders which weren't present in compiled form of apk. These all folders are generated from a file called resources.arsc present in compiled form which is absent in decompiled form


Such an example is of values folder which contains crucial xml files like styles.xml, strings.xml, ids.xml, etc

Always open xml files with Notepad++, it will mark commands and syntax making it look aligned and making it easy to understand


Example of decompiled xml file

Also, you can edit 9 patch files also which will be changed from now on

Example:-



We will discuss 9 png in detail later on

10. After you have done your modifications and you are ready to recompile the app, choose 11 (Compile System APK) if you are editing System App or 12(Compile Non-System App) if you are editing other than System App

11. a) If System App:-

After some time it will ask that if you want to copy additional files other than signatures to ensure less amount of errors, then choose y

After extracting some files, it will ask you to delete files from keep folder

Simply go to keep folder,
If you edited any pngs and there are many and you are lazy enough to delete one by one, then delete the whole folder in which you edited pngs


If you edited any xml file, then delete that xml file AND ALSO DELETE RESOURCES.ARSC


Why? Because we told that values and several other folders are generated from resources.arsc while decompiling
Now, if we don't delete resources.arsc, the modification we did in values folder will be reverted to original state


After doing this, go to script.bat again and press any key to continue


11. b)If its not system app:
Just recompile it and sign it man through the menu in apk multitool man.
It is easy as hell. Tutorial of non-system app has been ended here


12. Now, you will get another apk name System_ apkname.apk

Open both apks as archives by 7-zip


13. Last and most important step:-

Just drop the files you edited from new apk to old apk in correct folders. By now, you may have understood that resouces.arsc INCLUDES your edited xmls


14. Now, the final apk is not System_apkname.apk but apkname.apk (the original file you started with). Push it and enjoy













This is a work in progress.
Will add more things soon

Don't hesitate to ask any questions about anything


Credits:

@d3cka for teaching best about 9 pngs
@deathnotice01 for helping me
Miscellaneous Google and xda posts
The Following 46 Users Say Thank You to iamareebjamal For This Useful Post: [ Click to Expand ]
 
iamareebjamal
Old
(Last edited by iamareebjamal; 16th June 2013 at 05:25 PM.)
#2  
iamareebjamal's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 4,701
Posts: 3,604
Join Date: Aug 2012
Location: Batcave
Theming Part



General APK png Resources

 

Here I will tell you where to find some pngs to theme your Phone


Note: Here I will tell location of pngs but that may differ based on modification done to your ROM by OEMs or devs. These pngs are found after decompiling or extracting the apk files. For more reference, read this.

In this part, there is only brief information, but for a very good guide, please go here. I haven't covered it all up as d3cka himself has done a marvellous job in making that guide. All the things present in that guide should solve all your queries.

Quote:
General location of apks:

SystemUI.apk - /system/app/
framework-res.apk - /system/framework/
twframework-res.apk - /system/framework
framework.jar - /system/framework/
lidroid-res.apk - /system/framework/
Quote:
Variable list:

I have referred to some locations as drawable-xdpi. X here stands for

X: m, l, h, xh

Meaning pngs can be in drawable-mdpi, drawable-hdpi, drawable-ldpi, drawable-xhdpi depending on resolution of your phone

In some places, I have just added * in order to fill spaces that are not common in each png

[?] means maybe only for GB or Samsung


Battery Icons -

(i)Ice Cream Sandwich/Jelly Bean: SystemUI.apk/res/drawable-xdpi/stat_sys_battery**.png

(ii)Gingerbread: framework-res.apk/res/drawable-xdpi/stat_sys_battery**.png





Status Bar icons - SystemUI.apk/res/drawable-xdpi/
Note, some, however very few status bar icons are also present in framework-res.apk



Platlogo - framework-res.apk/res/drawable-nodpi/platlogo*.jpg

(image that pops up when repeatedly clicked on Android Version)
In Gingerbrad, its a single file but in ICS and JB, they are many images.



Default Wallpaper - framework-res/res/drawable-xdpi/default_wallpaper.jpg



Default Lockscreen Wallpaper[?] - framework-res.apk/res/drawable-xdpi/zzzzzzzz_default_lockscreenw.jpg
On stock based HTC roms, the default wallpaper location is specified in the.build.prop (so the dev can either swap out the image, or change the path)

The default wallpaper path for HTC roms is /system/customize/resource/wallpapers_a_00.jpg (Thanks to CNExus)





Spinners[GB] - framework-res.apk/res/drawable-xdpi/spinner_****_**.png
(The loading circles)




Menu Icons - framework-res.apk/res/drawable-xdpi/ic_menu_**.png

These icons may also be present in twframework-res.apk for Samsung Touchwiz ROMs


Notification Toggles

(i)With lidroid 15 toggles : lidroid-res.apk/res/drawable-xdpi/
(ii)Without lidroid mod : SystemUI.apk/res/drawable-xdpi


These were some general pngs of system apps that may be used to theme the phone. You can find respective pngs to theme in their apks.

Will add more soon...







9 PNG Discussion

 


These are special types of pngs that can be stretched to fit the need of program or different scenarios or cases. It contains 1 pixel lines on each border of different lengths for different things

As told above, we can't edit 9 png in compiled form as it will lose these lines which define its properties. So, we first need to decompile apk in order to edit 9 pngs


So, after decompiling apk, open 9 png in Photoshop and select the part inside that 1 px border and edit anything you want (Hue, Saturation, Bevel, Emboss, ANYTHING)


Now save it (save it as a normal png and then rename it as .9.png because photoshop doesn't recognise 9 png extension and image will loose its RGB format)

Explanation of 9 png:-


You can read this for more information


If you have doubt that you have gone wrong somewhere or you have made a new png from scratch and want to test if it is correct or not:
(Check all 9 png files you edit as they can cause Force Closes or bootloops)

Go to folder where you extracted android-sdk and go to tools folder and open draw9patch.bat


A window like this will open up:-

Drop you 9 png here
A new window will open with you 9 png on it
Tick on show bad patches


If you see red rectangles, you have a bad 9 patch image. You will need to delete or add those lines in png to remove all red boxes. If you want to delete, press Shift and start moving cursor over lines you want to delete. You can choose method of hit and trial to remove all rectangles and move the lower scale to see how your image size is adjusted


Or you can do what I do:

1. Remove all lines
2. Add single dot on top centre and left centre border of image (That can be taken as stretchable area)
3. Add lines on right and bottom of image where you want to fill content. Now, click on Show Content


The purple area you see in image is the content area (Text will be filled there. Eg:- Popup Menu)

4. Now, you can adjust these lines acoording to your need that what you want for stretchable area and content area until an unless there comes an red triangle

5. When it is done. Save the file. DONE

Easy, isn't it?
That's what theming is




Batch Editing pngs in Photoshop


 

Well the scenario is you have 200 pngs and you want to change their color, hue, add effect to them, etc. Definitely not worth the time you will spent doing this one by one. So, here, I will cover how to batch apply same edits on to your infinite pngs. Here, I am taking example of changing color of battery png from green to purple, you can apply any attribute to your image in the same way. I repeat it is not for .9.png files. Read above guide for reference

Let's start


1. First copy all your pngs you need to edit in a separate folder. I have made a folder named Battery Base and pasted my all pngs of battery there.


Now create another folder where your edited pngs will be saved. For eg:- Battery Done. (Don't create it inside Battery Base folder)

2. Open Adobe Photoshop and Choose Window>Actions or Alt+F9


3. Click on the note like file (Create new Action)


Rename it to anything you want . I have chosen Battery_color


Then click on Record. Now, you will see that red circle is enabled and now everything you do on image will be recorded and will be applied on each image.


4. Now, do this very carefully, don't miss any step.

We will do every thing that we want Photoshop to do with each file we want to edit.

a) So, first we want Photoshop to open the image. So , click on Open and choose any png from Battery Base folder (Choose a file with more color so that you know what color exactly your file will be after editing. That is why I chose 90 percent battery here).


b) Now, after opening, we want to change Color of png from green to purple. So, choose Image>Adjustment>Hue and Saturation or Ctrl+U


A dialog box with 3 sliders will appear. Move upper slider to change color. You can move other slider to change saturation and brightness if you want. Now, if you got it right, click on OK.

Every step of yours is being recorded, so don't do unnecessary stuff you don't want to do on other images. Nonetheless, if you have done it, then Drop down the Battery Base Action in action palette and you will see your every action there, If you want to delete any action , you can delete it from there. You can also add any action before pre completed action by clicking above that action and performing it.


Now, you can do anything you want to be done on your rest of pngs.

c) Now, we want Photoshop to save this png to carry on working on others. So, Go to File>Save as... and save it as a png in Battery Done folder. Photoshop will ask you to choose, so choose smallest compression and no interlace.


d) Image is saved but we also want Photoshop to close the png so that it does not open 200 tabs for editing 200 pngs. So, click on close (Small cross on title bar of png). If, it asks that do you want to save changes to png . Say no, because if you say yes, the png in Battery Base will be changes and when batch processing is done, that png in Battery Done will be of different color that all others.And also, your all green pngs in Battery Base folder will turn purple too. But we want purple images in Battery Done and green in Battery Base.

5. Now, we hae done what we want, so, we will stop recording the Action. Click on that square in Actions Palette.


6. Fun Starts. Now we will do the batch processing.

Go to File>Automate>Batch


In the dialog box, Choose the action to be Battery_Color (or obiviously any action you created)

Source folder: Battery Base

Destination Folder: Battery Done

Tick both Override Action 'Open' commands and Override Action 'Save as' commands


Click on OK. Sit back for 3 to 5 minutes(204 pngs) and TADA


You can apply any action in same way. Such as bevel, glossy, pale, etc to innumerous amount of pngs

The Following 30 Users Say Thank You to iamareebjamal For This Useful Post: [ Click to Expand ]
 
iamareebjamal
Old
(Last edited by iamareebjamal; 16th June 2013 at 03:09 PM.)
#3  
iamareebjamal's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 4,701
Posts: 3,604
Join Date: Aug 2012
Location: Batcave
Why APK-Multitool?

Yeah, why not just apktool or VTS (Virtuous Ten Studio)



But, when working with certain system apk files, there is a feature of APK Multitool that comes in very handy and that is, making a keep folder and asking you to delete stuff which you modded to then make an apk file. Certain files in apk do not need to be touched which can be easily controlled by APK Multitool.

Note: This is no way against VTS in any form

As I was making a guide which ensured least amount of errors, I chose APK Multitool, because we can easily fix those known errors od Status Bar disappearing or this and that

apktool is very minimalistic but not too user friendly for a newbie. And it may return with huge amount of errors if not used correctly.

So, APK Multitool is a perfect balance in between simplicity and work power
The Following 12 Users Say Thank You to iamareebjamal For This Useful Post: [ Click to Expand ]
 
iamareebjamal
Old
#4  
iamareebjamal's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 4,701
Posts: 3,604
Join Date: Aug 2012
Location: Batcave
FAQ
The Following 6 Users Say Thank You to iamareebjamal For This Useful Post: [ Click to Expand ]
 
iamareebjamal
Old
#5  
iamareebjamal's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 4,701
Posts: 3,604
Join Date: Aug 2012
Location: Batcave
Oops

Last One left
The Following 6 Users Say Thank You to iamareebjamal For This Useful Post: [ Click to Expand ]
 
Unnamed.Ace.User
Old
(Last edited by Unnamed.Ace.User; 20th June 2013 at 05:31 PM.)
#6  
Unnamed.Ace.User's Avatar
Senior Member
Thanks Meter 133
Posts: 359
Join Date: Apr 2013
Location: Vapi
Awesome guide areeb..
Will include this guide in the index for sure

-asdf-
The Following 3 Users Say Thank You to Unnamed.Ace.User For This Useful Post: [ Click to Expand ]
 
DD-Ripper
Old
#7  
DD-Ripper's Avatar
Recognized Themer
Thanks Meter 3,211
Posts: 1,445
Join Date: Jun 2012
Location: Assam
Will be a great guide for me

Sent from my GT-I9100 using Tapatalk 2
The Following User Says Thank You to DD-Ripper For This Useful Post: [ Click to Expand ]
 
XperienceD
Old
#8  
XperienceD's Avatar
Senior Member
Thanks Meter 2,397
Posts: 7,292
Join Date: Jul 2010
Location: Here =)
Great guide.
The Following User Says Thank You to XperienceD For This Useful Post: [ Click to Expand ]
 
prboy1969
Old
#9  
prboy1969's Avatar
Recognized Contributor
Thanks Meter 6,807
Posts: 10,166
Join Date: May 2009
Location: Michigan
Good info. Nice work
The Following User Says Thank You to prboy1969 For This Useful Post: [ Click to Expand ]
 
krazzyvishal
Old
#10  
krazzyvishal's Avatar
Senior Member
Thanks Meter 246
Posts: 344
Join Date: Oct 2011
Location: Mumbai

 
DONATE TO ME
This is a good guide, very good one. But, I've found that the latest APK Multi Tool doesn't work for Android 4.2.2 apks.
Does this one work? Any solution?
My homescreens: MyColorScreen
My apps on: Google Play

Always have your stuff when you need it with Dropbox. Sign up for free! http://db.tt/swcWMFA3
Want even more space? Come here: Copy or here: OneDrive

Thread Tools
Display Modes