yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] kevdog:
Perhaps some insight from the masters could be gleaned here.

Im trying to add 10% percentage icons to the battery for display.

I decompiled the stock framework-res.apk

I made modifications to the /res/drawable/stat_sys_battery.xml to reflect the addition of the new icons.

I added the icons into the /res/drawable-hdpi-v4 folder

I then modified the /res/values/public.xml file. In order to declare new ids for the new icons, within the "drawable" type, I found the last id hex value, and then sequentially added the new icon references in hex.

I recompiled using apk-manager. Sucess

I then used the old winrar method, and added the new icons and stat_sys_battery.xml file to the stock framework-res.apk. I then pushed the framework-res.apk back to the phone.

Net result -- the icons didn't show up.

I pulled this modified framework-res.apk and decompiled it. I received errors during the decompilation process. Here is one of the errors:

W: Could not decode attr value, using undecoded value instead: ns=android, name=drawable, value=0x01080361

The value referenced in this error was one of the values I added in the public.xml file.

Obviously something I did during this process did not work. Any insights would be appreciated.
[G1 Android Development] wayferer:
My understanding is that there is no need to modify the public.xml file (i didn't have to when doing the 1% icons). Also I believe that xml files must be compiled so you can't just overwrite them like images. Hope that makes sense and helps :)
[G1 Android Development] kevdog:
Which xml files specificially? I only changed the stat_sys_battery.xml so this is the only one I modifiied, (compiled all the framework), and then only added with the winrar process.

I have to add the winrar method because with the apk tool and the stock framework, if I simply decompile and then recompile framework-res.apk, the resultant apk is roughly 2x the size, and when I push and reboot, and get stuck in a boot loop with the bootanimation logo.
[G1 Android Development] Daneshm90:
make sure u copy over the new resources.arsc

Also try the beta i posted, specifically editing system apps ( no need for winrar method )
[G1 Android Development] kevdog:
Thanks Danesh -- I'll try that -- just one question which I've seen asked here before but maybe I was too dumb to understand any sort of explanation. When I take my framework and decompile and then recompile without any changes, why is the file size about 2x as big as the original, and why when I adb push it and reboot, do I get stuck in a loop with the boot animation? I guess my question comes down to -- why doesn't this decompile/recompile process simply work?
[G1 Android Development] Daneshm90:
That has something to do with apktool, if i recall (resources.arsc doesnt get compressed by apktool). U can always just use apk manager to compress ur app's pngs once extracted and it gets it down to similar size.

Also, refer to my posts a few pages back to explain why u get bootloops n wht process u must follow. Or just get the new beta and when compiling say yes to system app. Also check out the tips/help section of the script ;)
[G1 Android Development] kevdog:
OK I'm trying the new beta.

Couple of comments:

1. Log file complains about not find 7za although its in the other folder. Do I need to modify the PATH statement to include this directory. Funny since I have 7za as part of the cygwin package as well.

2. I really confused about the compilation of /system files. First I decompiled and added all the changes manually to the folder with the projects directory (added them to their respective folder). Then during compilation process, it asked in my case to delete the resources.arsc file as well as delete the modified xml and and pngs I had added in the drawable-hdpi folder. Seems like a duplication of work.

3. What option in your script compresses the png's specifically? Is this the batch optimize part?

Man -- I think I have to walk away from this for a few hours. I can't believe how many times it taken me unsuccessfully to change the stat_sys_battery.xml and add a few icons in the drawable-hdpi folder and then push back the framework-res.apk back to the phone -- all attempts unsuccessul. I'm sure Im missing something like the resources.arsc part, but possibly something else. It should not be this hard!!
[G1 Android Development] Daneshm90:
When it says delete anything u have modified it is referring to the "keep" folder, not ur project folder. All its doing is, w/e u don't delete from ur "keep" folder, it copies back into ur modified apk.

As for compressing, try option 2. I know it says option 1 must be selected, but the way i have reworked the script, it shouldn't matter.
[G1 Android Development] kevdog:
And the 7za problem??
[G1 Android Development] Daneshm90:
Not sure lol. Did u get tht with apk manager 4.8 as well ?

Anyway, for ur needs u don't need it.

Just decompile

Make ur changes

Compress images

Compile (say yes to system) follow through

Done

Edit : Nvm, are u getting that when compiling and saying yes to system apps ?
[G1 Android Development] kevdog:
Hey

I really sorry to keep bugging you -- trust me its hurting me as much as its hurting you

Didnt get error in 4.8. And yes I'm getting that error when trying to compile system app with 4.9beta:

The system cannot find the file specified.

'7za' is not recognized as an internal or external command,

operable program or batch file.

'7za' is not recognized as an internal or external command,

operable program or batch file.

The system cannot find the file specified.

The system cannot find the file specified.

'7za' is not recognized as an internal or external command,

operable program or batch file.

'7za' is not recognized as an internal or external command,

operable program or batch file.

The system cannot find the file specified.
[G1 Android Development] Daneshm90:
k hold up ill look through it n get back 2 u
[G1 Android Development] Daneshm90:
Hmm, when u select option 1 (Extract apk)

Do u get the same errors ?

Also for now, just copy 7za to c:\windows directory
[G1 Android Development] kevdog:
I dont choose option 1 -- I just pull the framework-res.apk manually, put it in the place-mod folder, and then choose decompile apk. I can tell you that during compilation of a system app, I get a lot of extracting lines flash by.

Will do as far as copying and putting in a directory within the PATH environment variable. I'm not sure you you set your path, but when I made batch files before, I would always copy the current path to a variable, then just add a directory to the path ~%dp, and then at the end of the script restore the old PATH. I haven't looked at your source, but I would bet you do something similar.

And lastly what I would like to do eventually is just push the changed files as update.zip (so that they can be installed on top of themes), rather than as an entire framework. Is there a way to make certain what files were changed? I know this would depend on exactly what each person was trying to do, but if just adding resources, would all that would be changed is the various xml files?, the icons (pngs), and the resources.arsc file?
[G1 Android Development] kevdog:
Well -- thanks a lot -- I was finally able to make this work to modify the resources.

I added a few lines in the stat_sys_battery.xml and added 4 pngs. I compress as you recommended. I guess my only question that remains is the final file size.

I started out with a framework-res.apk that was 2,589,240 bytes, and the resultant was 5,917,181 bytes. Thats over 2x the original size with not much more than 500kb added. I'm not sure exactly whats going on since whether I compressed or not -- the resultant file size was exactly the same.

Thanks for your input.
[G1 Android Development] Daneshm90:
Cool. Glad u got it working.
[G1 Android Development] hunterd13:
Daneshm90, just wanted to say thanks for making modding so easy. finally modified that ugly as sin aosp build!
[G1 Android Development] Mycorrhiza:
I am getting a "Java was not found" error although I have Java installed.

Can someone help?
[G1 Android Development] g00ndu:
Hi, it's me again. I tried to decompile my Settings.apk using option 9. After sometime, I got an error that reads:

Can't find framework resources for package of id: 2. You must install proper framework files, see project website for more info.
"An Error Occured. Please Check The Log (option 21)"
Press any key to continue ...

The log reads as follows:

--------------------------------------------------------------------------
|08/23/2010 Mon -- 18:36:37.45|
--------------------------------------------------------------------------
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)
Could Not Find C:\Documents and Settings\WATT\My Documents\Apk_Manager_Beta_4.9\place-apk-here-for-modding\../place-apk-here-for-modding/signedSettings.apk
Could Not Find C:\Documents and Settings\WATT\My Documents\Apk_Manager_Beta_4.9\place-apk-here-for-modding\../place-apk-here-for-modding/unsignedSettings.apk
I: Baksmaling...
I: Loading resource table...
W: Skipping "android" package group
I: Decoding resources...
I: Loading resource table from file: C:\Documents and Settings\WATT\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=theme, value=0x02070015
W: Could not decode attr value, using undecoded value instead: ns=android, name=textAppearance, value=0x0207000f
W: Could not decode attr value, using undecoded value instead: ns=android, name=textAppearance, value=0x0207000e
W: Could not decode attr value, using undecoded value instead: ns=android, name=textAppearance, value=0x0207000f
W: Could not decode attr value, using undecoded value instead: ns=android, name=textColor, value=0x02050000
W: Could not decode attr value, using undecoded value instead: ns=android, name=textColorHint, value=0x02050001

Please note that the Settings.apk was already deodexed (no error). I am confused as to why there are other resources that are needed. Can you help?

Many thanks.

Let me know what other information you require, oh and by the way, I'm using Samsung Galaxy S.
[G1 Android Development] Daneshm90:
U need to select the option to decompile with depenedencies. Then when it asks drag ur rom's second framework apk into it. It'll tell u if u did it right or no.
[G1 Android Development] g00ndu:
Bear with me a little longer, does it have to be an apk, or could it be a jar file too? Because in the framework folder, I have only 2 apks: framework-res.apk and twframework-res.apk. I tried it with twframework-res.apk but it is not the dependee of the Settings.apk

Edit: I will try every apk found in system/app and system/framework. Will also try to see if it can also be a jar file too.

Edit2: Trying every apk and jar in both the system/app and system/framework does not work. Doesn't find the dependencies.
[G1 Android Development] Daneshm90:
Yea, so when u select tht option, drag twframework-res.apk into the script and press enter. That should work.
[G1 Android Development] g00ndu:
Daneshm90, thanks for being so patient. I managed to resolve the problem. The problem is the Memory Size. I select option 20 and set it to 512 and the problem is gone.

Thanks! :)

Edit: I took a look @ the apktool directory, and there was 2 apk files; 1.apk and 2.apk. It looks like the framework resources is large. Just a suggestion, is it possible to set the memory size to the largest, example 512?
[G1 Android Development] Daneshm90:
Ah k cool. Btw are u using the new beta or 4.8 ? Im just looking for feedback before i take it out of beta.

Edit : U mean set it to that from start ? Well u can just open the script and look for set heapy=64 and change it to set heapy=512 ;)
[G1 Android Development] g00ndu:
Yes, I mean as default. But then again, I can understand that you have set it to 64, to cater for other phone models as well.

As to the 4.9, I have not extensively test it, but I can tell you, that I like 4.9 better, at least based on your intention, it suppose to copy back those files automatically, instead of manually as in 4.8.

Right now, I am learning the basics, before I go on to do a customized rom, of course, provided I have the time. Once again, thanks for such a great tool, appreciate your time and effort to make it even better.
[G1 Android Development] kevdog:
I thought I had everything worked out -- but Ive got to be missing something.

Using 4.9 beta

I restarted a new project.

I decompiled the stock framework

Within the projects folder:

I edited stat_sys_battery.xml.

I added icons to the /res/drawable-hdpi folder.

I recompiled selecting system app

I chose y for copying files over

Within keep folder, I deleted the resources.arsc along with stat_sys_battery.xml and all the icons (pngs) I added previously

The system said recompile is sucessful

I examined the new unsigned framework-res.apk

The new stat_sys_battery.xml was included

All the new icons I had added stat_sys_battery_0.png, ......(etc) where missing

I checked the log file:

W: Could not find sources

I: Checking whether resources has changed...

I: Building resources...

I: Building apk file...

The system cannot find the file specified.

Why aren't the newly added icon files included??

Originally included in the framework-res.apk file were the stat_sys_battery_x.png files had (x=0,20,40,60,80,100). I added (x=0,5,10,15,20,30,40,50,60,70,80,90,100).

Thanks for any help. It might be the late night and I'm not thinking right. Who knows.

Oh and Btw -- selecting 24 to quit -- sometimes it doesn't -- it keeps *****ing about the keep folder which isnt in the directory structure at all.
[G1 Android Development] kevdog:
Dang I must have peeved some people off here. Sorry
[G1 Android Development] kalpik:
I did the following:

1. Decompile.

2. Copied over stat_sys_battery.xml, stat_sys_battery_charge.xml and zzz_stat_sys_battery_1.xml

3. Copied over battery png files.

4. Chose compile.

5. Selected system APK.

6. Deleted the 3 xml files and all the png files I added from the "keep" folder.

But when I flash the resultant framework-res.apk, the battery icon just dissapears! Any clues?

Im using Galaxy S (GT-I9000).
[G1 Android Development] Daneshm90:
No lol. Its just i got a samsung galaxy and been playing with that for a while and barely visit this forum. Anyway, i'll look into that for you, remember its a beta its bound to have quirks :D For now just use 4.8 and manually copy over the files u didnt modify.

Make sure u delete the resources.arsc file as well.
[G1 Android Development] YoungSinema:
I can't compile after I decompile. I even decompiled, then compiled right away just to see if I get an error an I did. Here's the error:

xception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, -F, C:\Users\James\AppData\Local\Temp\APKTOOL1839046546659609986.tmp, -x, -0, arsc, -S, C:\Users\James\My Projects\Hero\Apk_Manager_4.8\other\..\out\res, -M, C:\Users\James\My Projects\Hero\Apk_Manager_4.8\other\..\out\AndroidManifest.xml]

at brut.androlib.res.AndrolibResources.aaptPackage(Unknown Source)

at brut.androlib.Androlib.buildResourcesFull(Unknown Source)

at brut.androlib.Androlib.buildResources(Unknown Source)

at brut.androlib.Androlib.build(Unknown Source)

at brut.androlib.Androlib.build(Unknown Source)

at brut.apktool.Main.cmdBuild(Unknown Source)

at brut.apktool.Main.main(Unknown Source)

Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, C:\Users\James\AppData\Local\Temp\APKTOOL1839046546659609986.tmp, -x, -0, arsc, -S, C:\Users\James\My Projects\Hero\Apk_Manager_4.8\other\..\out\res, -M, C:\Users\James\My Projects\Hero\Apk_Manager_4.8\other\..\out\AndroidManifest.xml]

at brut.util.OS.exec(Unknown Source)

... 7 more
[G1 Android Development] kevdog:
Ive taken a look at your script and here I think is where I'm running into problems:

This is within the :nq2 subsection

7za a -tzip "../place-apk-here-for-modding/unsigned%capp%" "../keep/*" -mx%usrc% -r

A few comments or questions:

-mx Parameter?? Dont know what this is

-m: Sets compression level -- Stored in variable %usrc%

-x: Exclude list

-mx:???

7za a: This adds files to archive, however would this be different if you just used the 7za u parameter which simply update files to archive???

I see what your script is doing, and its working different than what I thought was going on. Your basically compiling with apktool, and then simply using the using winrar copy method to paste all the unmodified files back in the archive excluding a few if its a system apk. So I see if some of the icons are not added, you can simply use this same method to add the missing files back in.

Lastly -- I don't know what is causing the quit error. There is nothing in the code that would make it function the way it does for me. I see that quit just pushes the script to the bottom where it is supposed to exit gracefully. Possibly here you could place some cleanup lines -- for example if checking for certain directories and if they exist -- delete them.

Only last suggestion would be to a third option for most entries -- for example y/n/quit or something like that. The quit would then return to the main menu. I can't tell you how many times I hit the wrong number like decompile for example, and then couldn't back out to the previous screen. I hit cntl-c to end the script, but then the system was complaining a process was still running and I eventually needed to reboot.

Lastly at the end -- under quit -- can you set the color back to the default color -- which I dont know the color combination for this -- the white text on black?

Thanks.
[G1 Android Development] :
Hi this is my first try editing a XML file so I'm probably doing a bunch of **** wrong and I've seen issues that looks like mine in other comments but I didn't really understand :P I try to edit a framework-res.apk file that I have previously done some png editing on. I select "decompile apk" and it works just fine. Then I replace 2 png's and edit a XML file. Then when I try to compile it again I get and error.

I've tried on version 4.5 - 4.9 but the same error. I'm sure it's me doing something wrong but maybe someone could explain to me the correct way to do it or link me to a site :)

Thx

Log.txt
[G1 Android Development] Daneshm90:
Try to decompile a stock (untouched) framework-res.apk for your firmware. Then make your edits and recompile.
[G1 Android Development] :
Nope still not working. Same error(s). Expect me doing even the easiest things wrong :p

BTW I just replaced all images with my old ones and edited the XML
[G1 Android Development] Daneshm90:
Are you sure its stock ? By stock i mean one that came with the rom on the basis that the rom was built from aosp and not just themed. If the apk is themed, those errors are expected.
[G1 Android Development] :
Took it directly from the stock ROM zip file. (Cronos FroYo 1.0.3)
[G1 Android Development] Daneshm90:
Wait a sec is it a sense rom ? If so u need to select the 2nd decompiling option (with dependencies) and when asked drag the com.htc apk into the script and press enter.
[G1 Android Development] :
No not Sense. I figured out some things and got half of it working :) Might get everything working now :D
[G1 Android Development] Daneshm90:
Ok, if u don't then provide me a link to the rom. I have a feeling its a themed rom and not stock aosp.
[G1 Android Development] :
It isn't themed. The reason I am getting these errors (might be new errors now) is because I am trying to add a png to make a smoother animation. And of course because I'm a noob I don't know how to do that :P So simple question. HOW THE HELL DO A DO THAT IT'S DRIVING ME CRAZY!!!!

Thanks :D

I successfully compiled a version where I didn't change any png's BTW :)
[G1 Android Development] Daneshm90:
Oh k so its ur modification thats causing the problems lol.

As for adding an image, look through this thread/apk tool's thread for posts where user added images for battery percentage, see how they did it. It should be relevant to you.
[G1 Android Development] :
Thanks for the help :D
[G1 Android Development] :
Looked around but it's a huge thread and I couldn't really find anything else than adding the image to Public.xml but I already tried that once with the same errors. If that's what I have to do I'll try again I might have made a mistake last time :)

EDIT: Think I'm mixing up things. Will try doing the Public.xml thing :p
[G1 Android Development] :
Warning noob question!

What is this: "....id="0x010802bd" />" and how do I find it? :p

Thanks
[G1 Android Development] kevdog:
I'm no expert, but many times you do not need to edit the Public.xml file. Resources only needed to be added here if they are referenced between functions, and not simply in a simple xml file. Just an fyi. Also if just editing an xml and adding a few pngs, the important parts are the resources.arsc file, the specific xml file, and the pngs -- that's all.
[G1 Android Development] wayferer:
Correct. When I did mine the public.xml was not edited. Just make sure to update the zip (after compiling) with assets / android manifest and the meta-inf folder from the original zip.
[G1 Android Development] :
I'm pretty sure resources.arsc is deleted when decompiling the apk. So what do you mean? Should I take it directly from the original apk and if so how do I edit it?

Keep in mind that this is my first time editing XML's :p

Thanks
[G1 Android Development] :
I just found out I had to many pngs in my original theme so I did a fail save way to delete them and then I wanted to test if I could compile it with all the themed pngs and no extra pngs or no code editing but now I get the same error again... Here's my log

Thanks
[G1 Android Development] cauli:
The error log is pretty explicit telling you what's wrong with your .9.pngs. Just a guess, but you do understand .9.pngs don't you? There needs to be a one pixel wide border around the png containing pixels which dictate how the png behaves when resized by android. These won't appear in the compiled png image but are essential to its compilation (the info is converted & stored as a data block within the png file).
[G1 Android Development] :
Yeah I do know what it is but the thing is that my theme is a combination of A LOT of themes :) I've taken all the good parts out of like 15 different black themes xD I don't think there's something wrong with the 9 pngs though. Will take a look at it anyways :) Thx

EDIT: Took a quick look but I really don't think there's anything wrong with them...

EDIT2: Wow it must be 1 or 2 pngs ****ing it all up. Some themer has ****ed up :/

EDIT3: Just tried compiling without any themed 9s and it worked fine :( Now I have to search for the needle in the haystack :/

Thanks for the help I didn't even think of the 9s...
[G1 Android Development] Brut.all:
You don't have to. You have all malformed files listed in the error message.

I think you don't know/understand that .9.png files are different in source/decoded and built/compiled form. You can't winzip some 9patch files and copy them to decoded app just like that, because they're in compiled form and they have to be decoded first.

Just open some unpacked 9.png file and then compare it to one decoded by apktool. Zoom in. Do you see black borders around? Yes, ithey're needed in all 9.png files, but they're "hidden" in compiled form.

I think easiest way is to decode these themes using apktool and copy decoded 9.png files to your project.
[G1 Android Development] :
Nope didn't know that (even though it's so easy and I should've figured it out) but I think i tried that once but might have been with all the extra pngs.... Will try again thx :)

EDIT: That certainly reduced the list :D Looks like one themer totally screwed up theming some buttons :/

EDIT2: YEEES! Finally got a fully themed compiled version :D :D :D Wow what a mess those themers had made xD Now it's just adding that extra PNG :)

EDIT3: WOOOOP! Just got a COMPILED version WITH the extra PNG :D :D :D Testing now :D
[G1 Android Development] :
YES! It worked!

Thanks to all who have helped me. I'm very grateful :D