Modifying the layout of the Joying Radio app.
version 0.2 See changelog at the bottom of this post.
This works in essence for most apks. There are some differences where the layout is defined in xml files or in json files.
Requirements:
java runtime version 7 or better.
apktool: (https://ibotpeaches.github.io/Apktool/)
Editor that handles unix LF correct. Any linux or Mac OS/X editor will do. Notepad on Windows does NOT. On Windows use Notepad++: (https://notepad-plus-plus.org/download/) for example.
Optional: ApkPack: (http://mirrors.gtxlabs.com/joying/3_Misc_Tools/ApkPack/)
Read(!!) the basic apktool Basic, Decoding, Building: (https://ibotpeaches.github.io/Apktool/documentation/) documentation to get a general understanding for the apk structure. It's about 1½ page and prevents a lot of questions.
Knowledge of working in a terminal / command box (some people still call this a DOS-box). These actions are not done using a nice graphical interface/program.
Installation of requirements:
Java: Either use Sun java: (https://www.java.com) for all platforms, Openjdk: (http://openjdk.java.net) for linux, or Mac OS/X's own java version (make sure it is version 7 or better)
apktool: See here: (https://ibotpeaches.github.io/Apktool/install/)
ApkPack.exe: This one can be used to pack/unpack the Allapp.pkg. This allows you to get the apks. Another option is to "adb pull" the original from your unit to work on.
apkPack is a windows binary but runs fine under wine.
General note
An apk file is actually nothing more than a zip file. This means that you can also unzip/rezip an apk. For only modifying buttons and other graphical elements, this is sufficient. When you also want to modify the layout of the main screen or sub-screens, you really need apktool to decompile/compile. If you want to do minor code changes, you also need apktool. (Also a java jar file is also nothing more than a zip file).
Note for Windows users
Text files contain lines (obvious). These lines end with CRLF ("\r\n") line endings on Windows (and MAC versions before OS/X). On linuxes/unixes they end with "\n".
For some files inside an apk this really matters! That's why you need an editor that can handle that correctly, like for example Notepad++.
Android is Case sensitive! Uppercase and lowercase characters do matter and are different (unless when used in strings)
Getting the radio apk
Copy one of my radio mods.
Use ApkPack.exe to get the apk out of the Allapp.pkg.
Use adb to copy the apk from the unit like "adb pull /system/app/JY-1-C9-Radio-V1.0/JY-1-C9-Radio-V1.0.apk ." (the last "." is not a typo). This assumes you already made a connection via USB or tcpip
Download the apk from "http://mirrors.gtxlabs.com/joying/1_Firmware/".
Install framework-res for use in apktool
This step might not be necessary for the radio apk, but is necessary if you modify apks that use system functions. It's anyway better to do this step.
Every Apktool release contains internally the most up to date AOSP framework at the time of the release. This allows you to decode and build most apks without a problem. However, manufacturers add their own framework files in addition to the regular AOSP ones. To use apktool against these manufacturer apks you must first install the manufacturer framework files.
Inside the 5009_60.zip (or previously the 5009_20.zip), you will find inside "/system/framework" the "framework-res.apk". Extract that one from the zip.
In a terminal window, you do on the command line:
Code:
<path_to>/apktool if <path_to>/framework-res.apk
You need to do this step for every new ROM upgrade from Joying.
Decompile the apk
Create some folder where you want to work on the apk.
Inside that folder do inside a terminal:
Code:
<path_to>/apktool d <path_to>/JY-JY-1-C9-Radio-V1.0.apk
(Change forward slash "/" to backward slash "" on windows.).
This will create a folder "JY-JY-1-C9-Radio-V1.0" containing the decompiled apk including the from-binary-to-UTF-8 text converted AndroidManifest.xml.
Code:
AndroidManifest.xml (file)
apktool.yml (file)
assets (folder containing "all kind of things" needed by the apk, but not belonging to the standard res structure. This can be images, files, scripts or even other apks)
original (folder containing original AndroidManifest.xml)
res (folder containing layout, graphics, translations, etc.)
smali (folder containing the decompiled code in "smali" format)
The "res" folder contains a large amount of sub folders.
The three most important folders are:
Code:
drawable-land-nodpi-v4 (contains resolution unspecific graphic elements for landscape mode)
drawable-nodpi-v4 (portrait version of above. Only needed because the original apk contains a corrupt png and can't be recompiled)
raw (contains screen config/layout in json formatted files. Most apks have the config/layout in straight xml)
Initial steps when using the original apk
When using the original apk (instead of one of my mods), you need two extra steps:
- Copy the "ic_point.png" from the folder "drawable-land-nodpi-v4" to the folder "drawable-nodpi-v4". As mentioned: that png is corrupt in the original "drawable-nodpi-v4" which makes that you can't recompile the apk.
- You need to make a small code change in smali to get rid of the "PS:" prefix in front of the PS-text containing the station name.
Edit the "smali/com/syu/radio/RadioController.smali" in a good editor! (NOT Notepad).
Search for the string "PS:" which is in line 1557.
Change:
Code:
const-string v3, "PS:"
into
Code:
const-string v3, ""
Relation between the graphical elements and the layout definition
All the graphical elements like buttons, the frequency ruler and numbers for the (big) frequency are in "res/drawable-land-nodpi-v4".
The layout definition is in "raw/radio_ui.json". The "radio_ui.json" determines which graphical elements are used, and how and where they are positioned. The "radio_ui.json" also determines which texts in which font and font size are used and where they are positioned.
Examples:
The big frequency ruler is named "type":"HorizontalRuler" in the radio_ui.json and defined by the graphical element "drawables":["bk_ruler"], where "bk_ruler.png" is the image. Note that in the json file no extensions (.png) are used.
The "type":"StationView" determines the 6 buttons with inactive (unselected: *_n), active (current selected: *_p) and "on_click/on_tap" (*_p) state. Note also that you will find a ' "extras":[30,0,0,0],' in these sections. This will offset the x-postion 30 pixels to the right. If you want to center the text, change it to: "extras":[0,0,0,0],
The Frequency numbers and the buttons left/right around it. The frequency numbers are the images "num_0.png" to "num_9.png", plus the "num_point.png". The buttons left/right are the "drawables":["ic_freqm_n", "ic_freqm_p"] (down) and "drawables":["ic_freqp_n", "ic_freqp_p"] (up).
The PS, TA, AF, PTY etcetera can easily be found. These do not contain "drawables" (images), but are defined by textsize and text color.
All elements are positioned in a "X0,Y0,X1,Y1" or "top_left_X, top_left_Y,bottom_right_X, bottom_right_Y] rectangle.
Actually this is all.
You can play with it to change the layout.
If you want to change color or form of buttons, ruler or other elements, you have to modify exiting elements or create new elements in either Gimp or Photoshop or another package you are familiar with.
Note1: most PNGs are stored in "optimized" color mode (only store used colors) instead of "RGB" color mode (use full color palette). On small PNGs this can reduce the files by a factor 2, thereby reducing your apk size from ~2 MB to ~1.5 MB. This also means that in Gimp or Photoshop (or whatever), you first need to set the color mode to "RGB" before altering the elements, and before saving them back to "optimized".
Note2: Remember that Android is case-sensitive. When working with the layout or the graphics, keep this in mind!
Recompile the apk
When you are done "playing" and you want to experience the great and glorious app you created, you need to recompile it.
In your folder where you have the unpacked folder "JY-JY-1-C9-Radio-V1.0", you do a:
Code:
<path_to>/apktool -c b JY-JY-1-C9-Radio-V1.0
- Note that you specify the folder name, not some apk name
- the "b" is for build.
- The "-c" is to use the original AndroidManifest.xml
If you see errors, please first google for it before asking questions. There is so much to find on this stuff on the web.
If your apk compiled successfully (don't mind the warnings), you will find it inside "JY-JY-1-C9-Radio-V1.0/disẗ" as a new "JY-JY-1-C9-Radio-V1.0.apk".
Push the apk to your unit.
Simply use one of the scripts from my repository. Make sure to have adb in the right place (windows) or change the script accordingly. Read the Readme: (https://github.com/hvdwolf/Joying-RootAssistant/blob/master/Radio-Mod/Readme.md) on my github repository inside the "Radio-Mod" section for info on how to use the scripts to install it on your unit.
Troubleshooting
Q1. adb or adb.exe can't be found.
A1. Make sure you have adb installed. Use the proper path to adb.
Q2. I can't get a connection to the unit.
A2. Search the web and find out how adb should work, see also the readme in my Radio mods. On 6.0.1 first activate adb over tcpip, or conect via USB.
Q3. You get an android icon instead of the Radio icon and when you tap it, your unit says "application not installed".
A3. Reboot, check again and try another time to copy it to your unit. If nothing works (after a couple of attempts), reboot and copy the original radio apk back in place, reboot again.
Q4. You rebooted the unit and you hear music, but you don't see a Radio icon.
A4. Same as Q3/A3: so do the same. This is due to the fact that the Radio function is a 2-step approach on the Intel joying units. The CarRadio.apk (hidden) does the real work. The Radio.apk is just the visible "tweak and go" app.
Changelog:
Version 0.2, 06 June 2017; few typos and rephrasing; Add reference to working in terminal / cmd box; Add paragraph on installing framework-res.apk as dependency for apktool.
Version 0.1, 05 June 2017; first version
Do you need to pull the framework file from the unit and load into apk tool first?
https://ibotpeaches.github.io/Apktool/documentation/#framework-files
I ran into issues on 6 with apktool until I loaded the framework.
gustden said:
Do you need to pull the framework file from the unit and load into apk tool first?
https://ibotpeaches.github.io/Apktool/documentation/#framework-files
I ran into issues on 6 with apktool until I loaded the framework.
Click to expand...
Click to collapse
Did you have issues with the Radio app or with the SofiaServer apk?
I tried with the framework that came with apktool (inside the jar) and with the framework-res.apk from the joying unit.
Apart from the issues you can encounter on this 6.0.1 version, I didn't notice differences for the Radio app.
I can imagine that with SofiaServer being a real system app, that it also might need the framework-res.apk.
However, normally when decompiling you get an error if you miss a "framework" type apk. It will even mention which apk you need. (Had that on my previous Samsung phone which uses a lot of Samsung only resource and framework like apks.
I will at least add a 5th Q/A section describing how to do that.
surfer63 said:
Did you have issues with the Radio app or with the SofiaServer apk?
I tried with the framework that came with apktool (inside the jar) and with the framework-res.apk from the joying unit.
Apart from the issues you can encounter on this 6.0.1 version, I didn't notice differences for the Radio app.
I can imagine that with SofiaServer being a real system app, that it also might need the framework-res.apk.
However, normally when decompiling you get an error if you miss a "framework" type apk. It will even mention which apk you need. (Had that on my previous Samsung phone which uses a lot of Samsung only resource and framework like apks.
I will at least add a 5th Q/A section describing how to do that.
Click to expand...
Click to collapse
I had issues when I made changes to the SofiaServer apk. I initially built against the 6.0.1 ROM using the 5.1.1 framework. I didn't see any errors, the apk just would not work when loaded on the unit. Now, I pull it from the ROM and load on every ROM update ( just to be safe).
gustden said:
I had issues when I made changes to the SofiaServer apk. I initially built against the 6.0.1 ROM using the 5.1.1 framework. I didn't see any errors, the apk just would not work when loaded on the unit. Now, I pull it from the ROM and load on every ROM update ( just to be safe).
Click to expand...
Click to collapse
I added a section and not as a new Q/A
Related
Okay I am trying to make some changes to my Rosie. I'm not going to ask how to make the changes I want I will hopefully figure it out myself....My question is about apktool. I keep getting FC on startup after trying to decompile and the build the rosie apk without making changes. What I've done
1) apktool d Rosie.apk
no errors ( Yes I have put the correct htc framework into apktool fw)
2)I Made no changes at all
cd Rosie
apktool b
3)I go to the build dir and the apk is there from here I have tried two different things
3a) Sign the apk using
java -jar signapk.jar testkey.x509.pem testkey.pk8 Rosie.apk your_app_signed.apk
3b)Leave the apk alone withouot signing it since it's a system app I dont think it needs to be signed, but I'm not sure
4) I put into a flashable file, in my update script I wipe dalvik cache as well, everything installs fine and I know this step isn't the issue
5) I reboot nand get constant FC so I have to pull the battery
I can't figure out why I'm getting this error so If anyone can help I would appreciate it alot....Thanks
it's not just Rosie I cant get to work....It's any apk...I decompile and build and they dont work with non changes....any ideas?
Hey bro I just started a thread on this in the theming section I'm with you on the Rosie.apk can't get it to work.
I haven't done system apps before, but I have successfully used apktool. There is (if it's different or maybe I'm just losing my mind) and additional tool called apk manager that utilizes the apk tool. That's what I've used that's so successful. It basically just gives you a list of choices with what to do with your apk. All you do is place the apk in the specific folder where the script can reach it and then run he script, make your choices, and bam. You have what you want. That could be either a system apk, regular apk, or a folder that's been decompiled. (I used a tool after that called j2gui that let's you take the .classes file and see a near perfect reproduction of the original java code).
Jack Attack!
I have had my fair share of dealings with Rosie, but apktool can do the job.
Everything up to Step 3 is good, although I don't 'cd' into Rosie, I just run:
apktool b Rosie from the previous folder.
Anyway, system files like Rosie do not need to be signed so scrap that route. The issue you have is with the new Rosie.apk that's been compiled not containing the original META-INF folder so won't be accepted by the system.
Check out this post that describes in full what I am trying to say. You'll want to focus on Step 3 and onwards in that post
i'm trying to do the same thing and i'm having a ton of different problems.
I believe about a month ago I checked the Apktool website and checked their list of bugs. There is a really nasty bug in the newest version (at the time I read it) where if you generated your .apk, then some things would be written incorrectly and of course would be the reason why your apps no longer work.
I'm gonna suggest you all check what versions you have and go to the previous version which worked great, or they might have fixed that already.
GgI am currently working on a major update to the apk manager application as well and changing the name to APK Multi-Tool with some new added features and also to fix some issues with some code errors.
I am also changing a lot of the features as well since a lot of the code has been outdated for a while.
I have updated all the files and modified Apk manager's Scripts to fix many user reported bugs from Daneshm90 apk manager which he had written a simple script to ease the process of editing apks. Got a lot of downloads so thought its in demand
Whether you're doing basic image editing or editing the smali or xml files, on average u have to use (Brut.all or JF's smali/baksmali) awesome tool to extract the apk, edit it, then sign the apk and then adb push/install it. This process is quite tiresome if you are testing a method that needs fine tweaking.
This script should make the process a LOT smoother.
Theres an option of compiling/signing/installing all in one step
Thanks:
Goes to Daneshm90 the Original Writer of APK Manager
Goes to Brut.all for his awesome tool.
Goes to JF for ofcourse, smali/baksmali
Features:
- Added framework dependent decompiling (For non propietary rom apks). (Option 10). Checks whether the dependee apk u selected is correct.
- Allows multiple projects to be modified, switch to and from.
- Allows to modify system apk's using apktool but ensures maximum compatibility in terms of signature / manifest.xml
- Batch optimize apk (Zipalign,optipng,or both)
- Batch Ogg optimization
- Batch install apk from script (option 19)
- Batch Theme Image Transfer TOOL
- Batch Theme optipng TOOL
- Batch Theme Zipalign APK TOOL
- Compression level selector (monitor status above menu)
- Error detection. Checks if error occurred anytime u perform a task, and reports it
- Extract, Zip apk's.
- Incorporates brut.all's apktool
- Improved syntax of questions/answers
- Logging on/off has been removed. Instead a log.txt is created which logs the activities of the script organized using time/date headers
- Optimize pngs (ignores .9.pngs)
- Pull apk from phone into modding environment.
- Push to specific location on phone
- Quick sign an apk (Batch mode supported)
- Read log (Option 24)
- Sign apks
- Supports batch installation, so if u drag multiple apks into the script (not while its running) it will install them all for u. U can ofcourse drag a single apk as well
- User can change the max java heap size (only use if certain large apks get stuck when decompiling/compiling apks) (Option 19)
- U can now set this script as ur default application for apks. When u do, if u double click any apk it will install it for u.
- Zipalign apks
- Much Much More
Instructions:
- Place apk in appropriate folder (Any filename will work, if running for first time folders will not be there, you must run and then the folders will be created)
- Run script
- Minimize the script
- Edit files inside the project folder
- Maximize the script
Requirements:
Java 1.7
Android SDK
FAQ
Resulting apk file is much smaller than original! Is there something missing?
First: compression of resources.arsc file. Sometimes this file is compressed in original apk, sometimes not and apktool always compress it. Second: lack of META-INF dir. Apktool builds unsigned apks, so they lack signatures stored in this dir. Third: apktool uses newest Android SDK, so it could optimize files better, especially if original app is old. So: unpack both original and resulting apk, remove META-INF from original and then compare sizes. If they're still much different, then you could report on XDA or somewhere.
There is no META-INF dir in resulting apk. Is this ok?
Yes. META-INF contains apk signatures mostly and after modifying apk in no longer signed, so there are no signatures in it. You have to sign resulting apk and then META-INF dir will be created.
What do you call "magic apks"?
Sometimes there are some apks which (for my current knowledge) are invalid, broken, theoretically they shouldn't exist. There may be many reasons of their existence: my lack of understanding of Android resources; some non-public, maybe future SDK tools or custom modifications of these; manual hacking of binaries, etc. Usually I can't do anything about it, but you could at least try to replace broken parts by something valid. Actually it's quite likely that they aren't even used, because if they would, then application would crash.
Got problems ?
1. Make sure your path has no spaces
2. Your filename has no wierd characters
3. Java/adb are in your path
4. It's not a proprietary rom's apk (aka Sense,Motorola,Samsung) (If u are, then use option 11 and drag the required framework, eg com.htc.resources, twframework-res...etc)
5. It's not a themed apk (if it is, expect .9 png errors, use as close to stock as possible)
6. Look at the log to know whats happening
7. If all else fails, post as much info as possible and we will try to assist you.
TO DO LIST
Add new feature to Randomly Generate a new Key File for signing the apk files after modifying and recompiling of the apk files this will also allow of uploading to the android market as this added feature will allow you to sign apk files that you may of compiled without signing beforehand.
Modify the Signapk script to be compatible with the Randomly Generation feature in the works
and a few other added features are in the works as I am redesigning the application and rewriting a lot of the code to fix issues as well as some of the new features have broken parts as some features have been moved and broken some command line prompts.
Installing APK Multi-Tool Itself
Instructions (Linux):
1-Download, create a folder in your sdk called "APK-Multi-Tool" and extract into it.
2-Goto the the "sdk/APK-Multi-Tool" folder and rename "Script.sh" to "script.sh".
3-Go into the "other" folder, right click on one file at a time, goto "permissions" in the new window and check the execute box.(do this with all the files)
4-To add the path to your folder open up a terminal and type in -
sudo su
PATH=$PATH:/THE PATH TO YOUR "SCRIPT.SH"
(for me this looks like the following)
PATH=$PATH:/sdk/APK-Multi-Tool/other/
5-export PATH
6-install "sox"
7-Type into the terminal "cd PATH TO YOUR SCRIPT.SH"
7.5 export PATH={PATH}:/PATH TO Your SDK/sdk/platform-tools/adb
8-Type "./script.sh"
9-You should have a running APK-Multi-Tool.
how to install sox:
Open the software center of the linux service and searched for sox. Installed it and it there you will have SOX working.
- Place apk in appropriate folder (Any filename will work, if running for first time folders will not be there, you must run and then the folders will be created)
- Open terminal and change-directory to APK-Multi-Tool(Easiest way is to type "cd ")
- Chmod 755 Script.sh
- Chmod 755 all files apps inside other folder
- Run script by typing ./Script.sh
- Minimize the script
- Edit files inside the out folder
- Maximize the script
Downloads:
https://github.com/APK-Multi-Tool/APK-Multi-Tool-Linux/archive/master.zip
Please check back daily or weekly as this project is under active Development and I am releasing Alpha releases on the website for Testing and bug reports.
Lol, why has nobody commented on this?
You're a savior. This is awesome. Can't wait for the rewrite.
AW: [Linux][UTILITY][TOOL] APK Multi-Tool
+1
Haven't seen this also available for Linux, so this is great.
Sent from my Galaxy Nexus using xda premium
Binary updates
UPDATED to apktool-cli-1.5.3-SNAPSHOT
-Updated to smali/baksmali to v1.4.2
-Fixed (issue #396) - Correctly handle android:debuggable while in debug
mode.
-Fixed (issue #340) - Fixed superclass errors on debug mode.
-Updated to Gradle 1.4
-Updated known bytes for configurations to 38 (from addition of layout
direction)
-Fixed NPE when handling odex apks even with --no-src specified. (Thanks
Rodrigo Chiossi)
-Fixed (issue #427) - Correctly handles `--frame-path` on uild
Error 404 on GitHub download page
xcly said:
Error 404 on GitHub download page
Click to expand...
Click to collapse
Fixed
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
I merged a few projects together instead of having multiple Android developer projects. I did some spring cleaning and deleted a few projects that was not useful and served no purposes. Also renamed the project organization which broke the link forgot to update lol.
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
I ran the script but I can't see any folders being created.. Trying to sign an apk. Looked up on google and all I can find is your instructions to put apk in appropriate folder (which I can't see..)
Thanks in advance
I will look into this ABCs see what's up
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
I ran the apksign tool separately using terminal for now
I got
The program sox is missing or is not in your PATH,
please install it or fix your PATH variable
If I go to the other folder there is no sox like in the windows version.
I will look into this asap once I get some free time
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
civato said:
I got
The program sox is missing or is not in your PATH,
please install it or fix your PATH variable
If I go to the other folder there is no sox like in the windows version.
Click to expand...
Click to collapse
I had the same problem but it was fixed once I installed sox. There was a tutorial on google search for setting up apk manager you might wanna have a look at.
Sent from my GT-I9300 using xda premium
raziel23x said:
I will look into this asap once I get some free time
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
Click to expand...
Click to collapse
xcly said:
I had the same problem but it was fixed once I installed sox. There was a tutorial on google search for setting up apk manager you might wanna have a look at.
Sent from my GT-I9300 using xda premium
Click to expand...
Click to collapse
I got it solved , I just entered the Ubuntu software center and searched for sox. Installed it and it works.
Maybe good to add this in OP when using linux. It is stupid of me thinking it was something harder so thank you for your help and fast response.
A other methode I found here
PS:
You don't need to type in ./Script.sh in teminal in linux , just clicking on it (Script.sh) and select "run in terminal" does the trick without typing anything.
updated the original post with detailed instructions
raziel23x said:
updated the original post with detailed instructions
Click to expand...
Click to collapse
Put updated info into the README file. Made a few corrections (hope you like).
AndyOpie150 said:
Put updated info into the README file. Made a few corrections (hope you like).
Click to expand...
Click to collapse
pushed your changed to github all code changes are welcome even forking the repo on github and making changes and doing pull request are welcome
raziel23x said:
pushed your changed to github all code changes are welcome even forking the repo on github and making changes and doing pull request are welcome
Click to expand...
Click to collapse
Just uploaded changed attachment. Fixed minor typos in Installation Instructions. Sorry I didn't get it straight before you pushed to github.
I deleted the info for Windows in previous attachments as well due to this being for the Linux version. Didn't know if you caught that.
PS: Thought I would let you decide if you liked my hair brained ideas first.
Is there any way to have a .jar file work without having to rename to .apk, or is that a mind bogling code rewrite. I'm all for learning.
Hey, I made some changes to the script to act more like the windows version of this tool. I added a setup.sh which will create all the folders and set permissions to everything. i also the ability to have multiple projects going at the same time, and also added a separate jar/dex folder so there is no need to rename the jar files to .apk to edit it. and other updates as well. its not 100% up to par with the windows one, but these few changes make a huge difference. Would you be interested in this?
---------- Post added at 11:38 AM ---------- Previous post was at 11:36 AM ----------
AndyOpie150 said:
Just uploaded changed attachment. Fixed minor typos in Installation Instructions. Sorry I didn't get it straight before you pushed to github.
I deleted the info for Windows in previous attachments as well due to this being for the Linux version. Didn't know if you caught that.
PS: Thought I would let you decide if you liked my hair brained ideas first.
Is there any way to have a .jar file work without having to rename to .apk, or is that a mind bogling code rewrite. I'm all for learning.
Click to expand...
Click to collapse
actually yes there is..i made an updated version of the script which has those features
clmowers said:
Hey, I made some changes to the script to act more like the windows version of this tool. I added a setup.sh which will create all the folders and set permissions to everything. i also the ability to have multiple projects going at the same time, and also added a separate jar/dex folder so there is no need to rename the jar files to .apk to edit it. and other updates as well. its not 100% up to par with the windows one, but these few changes make a huge difference. Would you be interested in this?
---------- Post added at 11:38 AM ---------- Previous post was at 11:36 AM ----------
actually yes there is..i made an updated version of the script which has those features
Click to expand...
Click to collapse
Make a pull request on github and in will merge it
Sent from my Xoom using Tapatalk HD
Hi Folks,
Overview
There is a mechanism in Android to override the resources and resource-id values within the framework-res.apk with "Vendor" Specified values. All of this is done transparently at runtime and leaves the original framework-res.apk intact and on the device.
CAUTION - ALWAYS HAVE A BACKUP HANDY. NORMAL OPERATION SHOULD BE FINE BUT WHILE PLAYING AROUND AND SEEING WHAT WAS POSSIBLE THE DEVICE DID CLEAR THE ACCOUNTS DATABASE A COUPLE OF TIMES
Background
While doing some research into how the resources.arsc file are handled internally on Android I came across a Document in the AOSP sources ( frameworks/native/libs/utils/README )
Along with a general overview of resource management, it contained a couple of interesting sections.
The resource overlay extension
------------------------------
The resource overlay mechanism aims to (partly) shadow and extend
existing resources with new values for defined and new configurations.
Technically, this is achieved by adding resource-only packages (called
overlay packages) to existing resource namespaces
...
The use of overlay resources is completely transparent to
applications; no additional resource identifiers are introduced, only
configuration/value pairs. Any number of overlay packages may be loaded
at a time; overlay packages are agnostic to what they target -- both
system and application resources are fair game.
The package targeted by an overlay package is called the target or
original package.
Resource overlay operates on symbolic resources names. Hence, to
override the string/str1 resources in a package, the overlay package
would include a resource also named string/str1. The end user does not
have to worry about the numeric resources IDs assigned by aapt, as this
is resolved automatically by the system.
As of this writing, the use of resource overlay has not been fully
explored. Until it has, only OEMs are trusted to use resource overlay.
For this reason, overlay packages must reside in /system/overlay.
Click to expand...
Click to collapse
What this essentially means is you can create a resource only apk which you place at /vendor/overlay/framework/framework-res.apk.
This file only needs to contain the resources you want to override, the document goes on to explain how the idmap is created in the resources-cache
Note the path is different from the readme file which suggests using /system/overlay, this is not referenced by the source and will do nothing.
Resource ID mapping
~~~~~~~~~~~~~~~~~~~
Resource identifiers must be coherent within the same namespace (i.e
PackageGroup in ResourceTypes.cpp). Calling applications will refer to
resources using the IDs defined in the original package, but there is no
guarantee aapt has assigned the same ID to the corresponding resource in
an overlay package. To translate between the two, a resource ID mapping
{original ID -> overlay ID} is created during package installation
(PackageManagerService.java) and used during resource lookup. The
mapping is stored in /data/resource-cache, with a @idmap file name
suffix.
The idmap file format is documented in a separate section, below.
Creating overlay packages
-------------------------
Overlay packages should contain no code, define (some) resources with
the same type and name as in the original package, and be compiled with
the -o flag passed to aapt.
The aapt -o flag instructs aapt to create an overlay package.
Technically, this means the package will be assigned package id 0x00.
There are no restrictions on overlay packages names, though the naming
convention <original.package.name>.overlay.<name> is recommended.
Example overlay package
~~~~~~~~~~~~~~~~~~~~~~~
To overlay the resource bool/b in package com.foo.bar, to be applied
when the display is in landscape mode, create a new package with
no source code and a single .xml file under res/values-land, with
an entry for bool/b. Compile with aapt -o and place the results in
/system/overlay by adding the following to Android.mk:
LOCAL_AAPT_FLAGS := -o com.foo.bar
LOCAL_MODULE_PATH := $(TARGET_OUT)/overlay
Click to expand...
Click to collapse
All this may sound very familiar to those who have built any AOSP Rom for a device as it is the same concept as the overlay tree which is contained in the device specified directories of the tree. Only this method executes at runtime instead of compile time. There are other differences. Mainly the runtime version only handles the drawables and resources which are included in the resources.arsc of framework-res ( at the moment ) where as the device overlay will handle any file you throw at it. You cannot unfortunately update compressed resources ( i.e the ones in the xml, raw, menu etc ).
The AOSP Tree also contained a test directory for this functionality . /frameworks/base/core/tests/overlaytests and contain an example implementation in the OverlayTestOverlay directory and a runtests.sh shell scripts which highlights that symlinking packages with custom names to framework-res is valid.
Summary
I think this will help modders out and has benefits over the currently widely used method of pulling a devices full framework-res and using apktool to unpack, making the changes and then repacking and resigning ( or using 7z replace, if you're lazy like me ) It will also help with applying/merging multiple mods from different sources as the files only need the include the very basic of the patch.
I don't know how long this functionality has existed but I have never seen it used by any oem and a search of Xda Didn't seem to show any "prior art" of the behaviour. I'd be interested on people thoughts on this, especially if you have seen a rom in the wild that uses it. It's maybe something that could be extended by "us" if google don't have any major plans for it possibly applied to other apks.
KNOWN ISSUES AND WORKAROUNDS
There is a bug in the /frameworks/base/libs/androidfw/AssetManager.cpp. It appears that a umask is set incorrectly when creating the idmap file from the overlay package, as such only the system user had access to it resulting in a failure to apply the overlayed values.
I chmod'd 666 /data/resource-cache/* and reboot to fix this. You can find further details in this google groups post. There is a patch attached the Post which I don't think will apply correctly as the source tree has been Refactored since the patch was created.
See below a workaround
Well this is fascinating. I am going to read the files this afternoon .
That is quite a cool find. Thanks for the tip.
Trevd, I gotta try this. I finally had time to read it carefully. I am going to make a simple one tomorrow. Have you had time to give it a whirl?
Oh, the Google groups link is wrong, I think. It only took me to the Google groups home page.
mateorod said:
Trevd, I gotta try this. I finally had time to read it carefully. I am going to make a simple one tomorrow. Have you had time to give it a whirl?
Oh, the Google groups link is wrong, I think. It only took me to the Google groups home page.
Click to expand...
Click to collapse
Fixed That google link for you, I'll attach some examples and try and put together some more resources on this. I'm going to test it on a couple of different devices. I can however confirm that the functionality is in the ICS code tree and I'm give it a test on CM9 on my HTC Sensations to make sure it functions as expected
Hello Again.
I've done something further research into "weaponizing" this mod so it can be used in anger. The Incorrect Permission Issue highlighted in the first post is pretty much a show-stopper if you want to use this in a flashable zip update for example.
Problem: The idmap is successfully created but cannot be used as the file the world readable file permission is not set.
Solution 1: Patch the AssetManager to create the file with the correct permissions.
This would work but results in the extra overhead of changing core android libraries and would more than likely break Stock OTA Updates because the file hashes won't match.
Solution 1a: Patch the AssetManager to create the file with the correct permissions, Submit the patch to the AOSP project so it is upstream for future releases.
The Patch in the google groups post does not seem to have been submitted as the issue is still there in the latest master branch ( 4.2.1 ) of the AOSP Project. I held off submitting it myself because it is basically someone else's work, However if no-one else is going to do it I suppose someone should . Obviously this solution is still dependent on google actually accepting the patch, carriers including it future roms and numerous other unknown factors which are out of your direct control.
Solution 2: Add a empty idmap in /data/resource-cache folder with the correct permission at the same time as adding the custom overlay.
Although a work around this does solve the issue. This is not as simple as just creating a placeholder zero byte file. The asset manager will reject the file when checking for stale cache files at startup. We need to actually create an empty idmap. Referring back to the original readme file (/frameworks/native/libs/utils/README), google explain the idmap file format
The ID map (idmap) file format
------------------------------
The idmap format is designed for lookup performance. However, leading
and trailing undefined overlay values are discarded to reduce the memory
footprint.
idmap grammar
~~~~~~~~~~~~~
All atoms (names in square brackets) are uint32_t integers. The
idmap-magic constant spells "idmp" in ASCII. Offsets are given relative
to the data_header, not to the beginning of the file.
map := header data
header := idmap-magic <crc32-original-pkg> <crc32-overlay-pkg>
idmap-magic := <0x706d6469>
data := data_header type_block+
data_header := <m> header_block{m}
header_block := <0> | <type_block_offset>
type_block := <n> <id_offset> entry{n}
entry := <resource_id_in_target_package>
Click to expand...
Click to collapse
They also go on to give an example.
idmap example
~~~~~~~~~~~~~
Given a pair of target and overlay packages with CRC sums 0x216a8fe2
and 0x6b9beaec, each defining the following resources
....
the corresponding resource map is
0x706d6469 0x216a8fe2 0x6b9beaec 0x00000003 \
0x00000004 0x00000000 0x00000009 0x00000003 \
0x00000001 0x7f010000 0x00000000 0x7f010001 \
0x00000001 0x00000000 0x7f020000
or, formatted differently
0x706d6469 # magic: all idmap files begin with this constant
0x216a8fe2 # CRC32 of the resources.arsc file in the original package
0x6b9beaec # CRC32 of the resources.arsc file in the overlay package
0x00000003 # header; three types (string, bool, integer) in the target package
0x00000004 # header_block for type 0 (string) is located at offset 4
0x00000000 # no bool type exists in overlay package -> no header_block
0x00000009 # header_block for type 2 (integer) is located at offset 9
Click to expand...
Click to collapse
Further analysis of the asset manager code suggests that although aapt won't create an empty overlay apk it is possible create an idmap file which just contains the file magic along with the original and overlay resources.arsc CRC32 which can be set at zero. Assuming little endian byte ording, these are those magic twelve bytes you need in the /data/resource-cache/[email protected]@[email protected]@idmap
Code:
69 64 6d 70 00 00 00 00 00 00 00 00
The file value will then be updated rather than created when a new overlay apk is provided.
[ EXAMPLES TO FOLLOW ]
So I don't know if anyone has done any follow-up with this, but we have a situation with the Xperia V (and T, more or less the same device in many respects) that makes it impossible to flash or push a modified framework-res.apk. Specifically, the resource-id's inside resources.arsc (public.xml) are getting mangled during recompile and while apktool doesn't show any errors (this is a known, reported issue), the apk is unusable and causes bootloops.
What you've presented here seems like a light at the end of the tunnel. But while I'm confident in my ability to follow directions, I'm afraid I'm too much of a noob to foresee possible reasons for this not working, which is basically what I'm requesting feedback on. Here's what I have in mind, please feel free to point out the holes in my plan...
1. Create the overlay, with the config.xml containing the proper resource-id's as found in public-xml.
2. Push the overlay. It seems to me that with an unmodified framework-res.apk in place, the overlay will simply replace the values from resources.arsc with identical values, thereby having no effect on the system. Any problems at this stage, then, would be from errors on my part, and naturally I would rather weed them out before the next step...
3. Push a modded framework-res.apk and hope that with the overlay in place and doing its business, the corrupted resource-id's will be quarantined and unable to wreak havoc on the system.
It sounds easy, so I'm sure I've missed something. I appreciate any feedback, scathing or otherwise.
shockwaverider said:
So I don't know if anyone has done any follow-up with this, but we have a situation with the Xperia V (and T, more or less the same device in many respects) that makes it impossible to flash or push a modified framework-res.apk. Specifically, the resource-id's inside resources.arsc (public.xml) are getting mangled during recompile and while apktool doesn't show any errors (this is a known, reported issue), the apk is unusable and causes bootloops.
What you've presented here seems like a light at the end of the tunnel. But while I'm confident in my ability to follow directions, I'm afraid I'm too much of a noob to foresee possible reasons for this not working, which is basically what I'm requesting feedback on. Here's what I have in mind, please feel free to point out the holes in my plan...
1. Create the overlay, with the config.xml containing the proper resource-id's as found in public-xml.
2. Push the overlay. It seems to me that with an unmodified framework-res.apk in place, the overlay will simply replace the values from resources.arsc with identical values, thereby having no effect on the system. Any problems at this stage, then, would be from errors on my part, and naturally I would rather weed them out before the next step...
3. Push a modded framework-res.apk and hope that with the overlay in place and doing its business, the corrupted resource-id's will be quarantined and unable to wreak havoc on the system.
It sounds easy, so I'm sure I've missed something. I appreciate any feedback, scathing or otherwise.
Click to expand...
Click to collapse
Hi There.
It's sound's plausible. I will say that I was attempting to implement this "trick" on a Samsung Galaxy Note 10.1 which had a TouchWiz Rom installed without any luck. In that case it wasn't retaining the correct permissions for the resource-cache directory. I didn't go as far as patching the init binary... yet!!! I think that will probably sort it out with if you have control of the device so there is still hope on that one.
I've also not tested it with anything other than settings found in the config.xml I suppose if it gets compiled into the resources.arsc it should be alright.
Have you tried recompiling the using aapt instead? I'm afraid I'm no expert on aapt and it's many switches so I'm afraid you're are on your own as far a making the apk goes if you are trying this outside of the AOSP source tree!
Good Luck
trevd said:
Hi There.
It's sound's plausible. I will say that I was attempting to implement this "trick" on a Samsung Galaxy Note 10.1 which had a TouchWiz Rom installed without any luck. In that case it wasn't retaining the correct permissions for the resource-cache directory. I didn't go as far as patching the init binary... yet!!! I think that will probably sort it out with if you have control of the device so there is still hope on that one.
I've also not tested it with anything other than settings found in the config.xml I suppose if it gets compiled into the resources.arsc it should be alright.
Have you tried recompiling the using aapt instead? I'm afraid I'm no expert on aapt and it's many switches so I'm afraid you're are on your own as far a making the apk goes if you are trying this outside of the AOSP source tree!
Good Luck
Click to expand...
Click to collapse
Thanks for the input! I haven't tried compiling using aapt, I'm afraid that I'm working way beyond my abilities here due to a mix of frustration and determination. I ended up here after somebody pointed to barrykr's thread HERE, so I suppose the first thing to do is try out his method and see what comes of it. If it's not successful, then I'll try to sort through all the big words and smart-people talk and figure out how to get it to work.
Hey mate... just noticed this thread of yours. This is awesome... I wonder why it didn't draw more attention.
Anyway... you've probably seen my mods thread over at Rootzwiki, right? I was wondering if this "overlay" thing would actually work for SystemUI too?
shockwaverider said:
So I don't know if anyone has done any follow-up with this, but we have a situation with the Xperia V (and T, more or less the same device in many respects) that makes it impossible to flash or push a modified framework-res.apk. Specifically, the resource-id's inside resources.arsc (public.xml) are getting mangled during recompile and while apktool doesn't show any errors (this is a known, reported issue), the apk is unusable and causes bootloops.
[...]
Click to expand...
Click to collapse
Hi there! Just wanted to let you know that I have successfully made an overlay.apk which overrides the framework-res.apk default 'settings'. I have a Xperia S with the same problem with framework-res.apk. For my example I used the showNavigationBar boolean value and edited it, and the navigation bar showed after boot :victory: :victory:
@trevd I have not time to test this now, but do you know if it is possible to make an overlay.apk, only with images instead of the resource file? Thanks, I'm quite exited now
edit. Yes it is possible with images. ****. I'm in heaven right now. Everything will be soooo much easier.
skifyr123 said:
Hi there! Just wanted to let you know that I have successfully made an overlay.apk which overrides the framework-res.apk default 'settings'. I have a Xperia S with the same problem with framework-res.apk. For my example I used the showNavigationBar boolean value and edited it, and the navigation bar showed after boot :victory: :victory:
@trevd I have not time to test this now, but do you know if it is possible to make an overlay.apk, only with images instead of the resource file? Thanks, I'm quite exited now
Click to expand...
Click to collapse
@skifyr123 That's a pleasant surprise, I was under the belief that it had stopped working... maybe I was doing my own mod wrong ..
The example in the aosp includes images. http://androidxref.com/4.2_r1/xref/...ytests/OverlayTestOverlay/res/drawable-nodpi/ . I don't know whether you can exclude resources, however that shouldn't be an issue as you can "override" a resource that doesn't exist so won't effect anything. I suspect you probably can excluded them...... as we say in the trade "Try it yourself"
@Kookie_Monster : No , I'm fairly certain that it won't the code only handles framework-res... however there a comment in the code that is quite interesting http://androidxref.com/4.2_r1/xref/frameworks/base/libs/androidfw/AssetManager.cpp#198 Line 198. "apps are handled by the Java Package Manager", I'll have to look deeper into that one
Images worked Do you know if this is any different from Xposed engine (http://forum.xda-developers.com/showthread.php?t=1574401).. At least in this you don't have to install anything extra.
skifyr123 said:
Images worked Do you know if this is any different from Xposed engine (http://forum.xda-developers.com/showthread.php?t=1574401).. At least in this you don't have to install anything extra.
Click to expand...
Click to collapse
Hi
I keep hearing things about the Xposed engine, It's looks a very cool project although not something I'd ever use.
Yes this is completely different It's part of Android core platform source code and is implemented by the asset manager http://androidxref.com/4.2_r1/xref/frameworks/base/libs/androidfw/AssetManager.cpp I believe it's been in there since day 1 ( or close enough ). The main difference is Xposed will let you code where as this is limit to certain types of resources.
I'm GUESSING that this was the original method for vendor overlays but possibly not picked up by HTC ( and others ) in Android's early days so the Idea was abandoned, the way the README in the AOSP reads it was fully intended to extend much more than the framework-res. With all that in mind I also wouldn't be surprised if it suddenly disappeared one day because there's no oem's ( that I know of ) using it
skifyr123 said:
Hi there! Just wanted to let you know that I have successfully made an overlay.apk which overrides the framework-res.apk default 'settings'. I have a Xperia S with the same problem with framework-res.apk. For my example I used the showNavigationBar boolean value and edited it, and the navigation bar showed after boot :victory: :victory:
@trevd I have not time to test this now, but do you know if it is possible to make an overlay.apk, only with images instead of the resource file? Thanks, I'm quite exited now
edit. Yes it is possible with images. ****. I'm in heaven right now. Everything will be soooo much easier.
Click to expand...
Click to collapse
You, sir, are my hero!! :good: :good: :good:
Thank You.
trevd said:
Hi Folks,
Overview
There is a mechanism in Android to override the resources and resource-id values within the framework-res.apk with "Vendor" Specified values. All of this is done transparently at runtime and leaves the original framework-res.apk intact and on the device.
CAUTION - ALWAYS HAVE A BACKUP HANDY. NORMAL OPERATION SHOULD BE FINE BUT WHILE PLAYING AROUND AND SEEING WHAT WAS POSSIBLE THE DEVICE DID CLEAR THE ACCOUNTS DATABASE A COUPLE OF TIMES
Background
While doing some research into how the resources.arsc file are handled internally on Android I came across a Document in the AOSP sources ( frameworks/native/libs/utils/README )
Along with a general overview of resource management, it contained a couple of interesting sections.
What this essentially means is you can create a resource only apk which you place at /vendor/overlay/framework/framework-res.apk.
This file only needs to contain the resources you want to override, the document goes on to explain how the idmap is created in the resources-cache
Note the path is different from the readme file which suggests using /system/overlay, this is not referenced by the source and will do nothing.
All this may sound very familiar to those who have built any AOSP Rom for a device as it is the same concept as the overlay tree which is contained in the device specified directories of the tree. Only this method executes at runtime instead of compile time. There are other differences. Mainly the runtime version only handles the drawables and resources which are included in the resources.arsc of framework-res ( at the moment ) where as the device overlay will handle any file you throw at it. You cannot unfortunately update compressed resources ( i.e the ones in the xml, raw, menu etc ).
The AOSP Tree also contained a test directory for this functionality . /frameworks/base/core/tests/overlaytests and contain an example implementation in the OverlayTestOverlay directory and a runtests.sh shell scripts which highlights that symlinking packages with custom names to framework-res is valid.
Summary
I think this will help modders out and has benefits over the currently widely used method of pulling a devices full framework-res and using apktool to unpack, making the changes and then repacking and resigning ( or using 7z replace, if you're lazy like me ) It will also help with applying/merging multiple mods from different sources as the files only need the include the very basic of the patch.
I don't know how long this functionality has existed but I have never seen it used by any oem and a search of Xda Didn't seem to show any "prior art" of the behaviour. I'd be interested on people thoughts on this, especially if you have seen a rom in the wild that uses it. It's maybe something that could be extended by "us" if google don't have any major plans for it possibly applied to other apks.
KNOWN ISSUES AND WORKAROUNDS
There is a bug in the /frameworks/base/libs/androidfw/AssetManager.cpp. It appears that a umask is set incorrectly when creating the idmap file from the overlay package, as such only the system user had access to it resulting in a failure to apply the overlayed values.
I chmod'd 666 /data/resource-cache/* and reboot to fix this. You can find further details in this google groups post. There is a patch attached the Post which I don't think will apply correctly as the source tree has been Refactored since the patch was created.
See below a workaround
Click to expand...
Click to collapse
is't possible to use vendor overlay to add/ change a value in build.prop file ?
Can someone solve this? I tried to make an overlays to my rom by placing the overlays to /system/vendor/overlays. It works. But when I try to changing to other themes, my overlays gone, I tried to reapply stock theme but didn't worked. Must I try another folder like /system/overlays?
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 :laugh:
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
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
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
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.
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/
Click to expand...
Click to collapse
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
Click to expand...
Click to collapse
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
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 :victory:
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
FAQ
Oops
Last One left
Awesome guide areeb..
Will include this guide in the index for sure
-asdf-
Will be a great guide for me
Sent from my GT-I9100 using Tapatalk 2
Great guide.
Good info. Nice work :good:
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?
krazzyvishal said:
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?
Click to expand...
Click to collapse
Thanks for notifying
You can try downloading this - http://d-h.st/cze and replacing the previous files with the new files in others folder
It's by Rizal Lovin from his guide here http://forum.xda-developers.com/showthread.php?t=2195680
Or you can notify the bug (if it's a bug ) here http://forum.xda-developers.com/showthread.php?t=1310151
Best theming guide i ever seen
i love ur ,9 pngs method and how u explained us more deeply about them
Thanks
krazzyvishal said:
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?
Click to expand...
Click to collapse
Try some of the suggestions in my guide. Link below.
From me to you.
great guide for starters
all hail to areeb
iamareebjamal said:
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)
Click to expand...
Click to collapse
Here's what i do if i want to keep the .9.png border intact:
Open my .9.png.
Select>All.
Select>Modify>Border. Set width at 1 pixel.
Select>Inverse.
Edit>Cut.
Edit>Paste special>Paste in place.
Layer>Arrange>Send to back.
This splits the the border from the image allowing you to edit the image freely without affecting the 9patch.
I'll attach my action i created to automate the process.
Extract the action from the zip.
Window>Actions.
Select dropdown menu.
Load actions> select split.9.atn
One final thing. Photoshop has no problems with the .9.png extension. When you save your image (save for web) it will show as .png, just insert .9 into the name. I've never had a problem.:good:
Appreciate! Great guide
dully79 said:
Here's what i do if i want to keep the .9.png border intact:
Open my .9.png.
Select>All.
Select>Modify>Border. Set width at 1 pixel.
Select>Inverse.
Edit>Cut.
Edit>Paste special>Paste in place.
Layer>Arrange>Send to back.
This splits the the border from the image allowing you to edit the image freely without affecting the 9patch.
I'll attach my action i created to automate the process.
Extract the action from the zip.
Window>Actions.
Select dropdown menu.
Load actions> select split.9.atn
One final thing. Photoshop has no problems with the .9.png extension. When you save your image (save for web) it will show as .png, just insert .9 into the name. I've never had a problem.:good:
Click to expand...
Click to collapse
Thanks for suggestions
About last thing, I never said anything about Photoshop having problems with .9.png files
Maybe words appeared different from what they meant
iamareebjamal said:
Thanks for suggestions
About last thing, I never said anything about Photoshop having problems with .9.png files
Maybe words appeared different from what they meant
Click to expand...
Click to collapse
Sorry, my bad. I didn't mean it had problems. What I was trying to say is you can just add the .9 without any problems.
Normally I just copy the nines into a separate folder, work on them, then when saving double click and replace. Doesn't save much time with a handful, but when you have quite a lot it all adds up. Plus you still have the originals incase of an error.
dully79 said:
One final thing. Photoshop has no problems with the .9.png extension. When you save your image (save for web) it will show as .png, just insert .9 into the name. I've never had a problem.:good:
Click to expand...
Click to collapse
I think you're using a step or two more than you need to layer the border, and to save I just merge the layers, save and close.
XperienceD said:
I think you're using a step or two more than you need to layer the border, and to save I just merge the layers, save and close.
Click to expand...
Click to collapse
What steps are they? When it's automated using the action it takes less than a second.
Everyone has their own technique, personally I think merging layers and saving is redundant as they are merged when saved.
Hello
I've tested quite a few roms and found a feature I live very much, it's called dynamic navbar - however I've found a Rom that I absolutely love and it's pure nexus, as much as I love it there is a huge downside for me and that's the lack of dynamic navbar.
I have seen a app on play store called "navbar apps" but u don't like it, and I've seen that you can extract the framework and edit via a pc. But is there a way to enable dynamic navbar on PN without those two options? Preferably via the phone.
Thanks
MrCreel said:
Hello
I've tested quite a few roms and found a feature I live very much, it's called dynamic navbar - however I've found a Rom that I absolutely love and it's pure nexus, as much as I love it there is a huge downside for me and that's the lack of dynamic navbar.
I have seen a app on play store called "navbar apps" but u don't like it, and I've seen that you can extract the framework and edit via a pc. But is there a way to enable dynamic navbar on PN without those two options? Preferably via the phone.
Thanks
Click to expand...
Click to collapse
Hello... Either use the mentioned app or do the changes in your framework. But you'll likely have to do it for every updates as the developer often makes change in the framework. Maybe you could maybe kindly make a request to the developer?!
Good luck...
MrCreel said:
Hello
I've tested quite a few roms and found a feature I live very much, it's called dynamic navbar - however I've found a Rom that I absolutely love and it's pure nexus, as much as I love it there is a huge downside for me and that's the lack of dynamic navbar.
I have seen a app on play store called "navbar apps" but u don't like it, and I've seen that you can extract the framework and edit via a pc. But is there a way to enable dynamic navbar on PN without those two options? Preferably via the phone.
Thanks
Click to expand...
Click to collapse
Just follow this 2 guides...
https://forum.xda-developers.com/nexus-6/general/guide-dynamic-nav-bar-android-l-m-n-t3515080
https://forum.xda-developers.com/android/apps-games/guide-enable-pixel-launcher-round-icon-t3536267
Basically you have to edit the framework-res.apk, obviously you have to be rooted, install the requirements on the second link, here I'll summarize the steps I follow, but if you have any doubt read and follow the 2 guides, the second one to decompile and compile the apk and the first one indicates the lines you have to change and the files in which you find them.
List of tools that we need
1. JDK, download it here http://www.oracle.com/technetwork/ja...sp-138363.html
2. Apktool, download it here https://ibotpeaches.github.io/Apktool/
3. Root Explorer
4. Text Editor
STEP 1 - Get the firmware-res.apk
First you need your own device firmware-res.apk, it is located here \Root\System\framework\
STEP 2 - Copy firmware-res.apk to the same folder with Apktool.jar
I recommend locate it on folder easy to located like desktop folder
STEP 3 - Decompile firmware-res.apk
Open CMD on your folder (on windows use [shift + right click -> open command window here]) that firmware-res.apk and Apktool.jar located and run this command
java -jar apktool.jar d framework-res.apk
STEP 4 - Open styles.xml and change values
Navigate to res, values, and open styles.xml with your text editor of choice (located at \framework-res\res\values\styles.xml)
Search for "navigationBar". There will be three instances of it. You only have to change the last two. Change "@colorBlack" to "?colorPrimaryDark" and save your changes
STEP 6 - Open colors.xml and change values
Navigate to res, values, and open colors.xml with your text editor of choice (located at \framework-res\res\values\colors.xml)
Open colors.xml and search for "input_method_navigation_guard". Change "ff000000" to "00000000" and save the file. If you don't change this, the navigation bar will turn black when you open the keyboard
STEP 7 - Compile your framework-res.apk
Code:
java -jar apktool.jar b framework-res -c
STEP 8 - Replace old firmware-res.apk with the new one
Copy your new compiled firmware-res.apk in framework-res\dist to your Android Device \Root\System\framework\. It is recommended to backup the default framework.res-apk first
Note: It is recommended to copy it from recovery, but you can also copy it directy via root explorer but your device will restart instantly
I do not take credit for this guide, do thank the op's if you find it useful.
Also is not perfect as a custom integration but it's something.