[tutorial]**Fix for recompiling framework-res with apktool** 4/15/2012

Search This thread

he_stheone64

Senior Member
Aug 1, 2008
5,033
10,991
Düsseldorf
Since many of you guys might only be in need to decompile all the .9`s in com.htc.resources, there is a workaround that allows you to compile these.

Decompile with:

1. java -jar apktool.jar d --keep-broken-res com.htc.resources.apk com.htc.resources-decoded

This ignores all errors and decompiles the apk incl. all patched pngs.

2. Make your changes and copy the changed png`s in any given decompiled apk (I use calendarprovider.apk for this task, very slim apk, compiles fast...) and compile them

I will look into the current state and see, whether I can brute force the apk to build :D
 
Last edited:

fisha21

Senior Member
Nov 23, 2007
2,331
4,379
Certainly you can address a lot of areas, but I don`t like half baken Themes, so I decided not to publish the Skin and Theme, that is basically ready.

I know exactly what you mean...I had to go from v0.1 to v2.1 before I had something I was happy to release. Still new to m.10 editing, so I'm not entirely sure what aspects of Sense these control. Hopefully you'll manage to find a workaround for the com.htc.resources issue.

Any ideas how the stock skins are able to change the lockring, but custom skins cannot?


Edit: you posted your workaround while I was typing this...fast work! I will try that out a bit later and let you know how it works. To be honest, I'm prob more keen to get at the xmls in there. Have managed to sort most of the .9.pngs by making the custom skin....a trick I learnt from you, by the way, so thanks for that :D


Sent from my HTC One X using xda premium
 
Last edited:

he_stheone64

Senior Member
Aug 1, 2008
5,033
10,991
Düsseldorf
It`s not only the lockring, same issue with Rosie dock...

You will also have all xml`s decompiled with this workaround, but now compiling them successfully will be a bigger task. In any case now you have a base to start fixing issues, which is more likely then staring at a base of empty folders :D
 
Last edited:

chrisch1974

Inactive Recognized Developer
Feb 3, 2011
920
3,647
It`s not only the lockring, same issue with Rosie dock...

You will also have all xml`s decompiled with this workaround, but now compiling them successfully will be a bigger task. In any case now you have a base to start fixing issues, which is more likely then staring at a base of empty folders :D

For fixing the recompiling you first need to fix the *ERR* folders and get their correct names. Or you are maybe going to loose the correct dimension values for your resolution.
 

he_stheone64

Senior Member
Aug 1, 2008
5,033
10,991
Düsseldorf
Thx chrisch - I certainly did that already and dimens values are just fine in the correct value folders. Can someone upload framework-res.apk from One X ROM? - Edit: got it already...

In any case I can only spend a very limited amount of time on this project (since I use a One S), but using this base I`m sure you have enough good guys here in One X forum to go fo it.
 
Last edited:

Scabes24

Inactive Recognized Themer
Aug 24, 2008
2,498
876
Seattle, WA
I know exactly what you mean...I had to go from v0.1 to v2.1 before I had something I was happy to release. Still new to m.10 editing, so I'm not entirely sure what aspects of Sense these control. Hopefully you'll manage to find a workaround for the com.htc.resources issue.

Any ideas how the stock skins are able to change the lockring, but custom skins cannot?



Sent from my HTC One X using xda premium
Some of the images & colors used for the stock skin.apks are in the m10 files in fusion.apk.


Sent from my HTC One X
 
Last edited:

he_stheone64

Senior Member
Aug 1, 2008
5,033
10,991
Düsseldorf
For fixing the recompiling you first need to fix the *ERR* folders and get their correct names. Or you are maybe going to loose the correct dimension values for your resolution.

chrisch - do you have a clue about the correct names needed for the ERR folders? I was able to track down all errors, but without the correct folder names, these will surely not compile properly.
 

chrisch1974

Inactive Recognized Developer
Feb 3, 2011
920
3,647
chrisch - do you have a clue about the correct names needed for the ERR folders? I was able to track down all errors, but without the correct folder names, these will surely not compile properly.

I'm not sure atm. I was comparing it with a Sense 3.5 GB com.htc.resources and there are some folders missing now like values-w1dp-hdpi, values-w2dp-hdpi, values-w4dp-hdpi and values-w5dp-hdpi. But really not sure which ones are missing too.

I'm also trying to catch them with aapt atm. But looks like a pain.

For the moment you could try to delete the *ERR* folders and try to fix the rest to rebuild it. It will result in a not 100% correct com.htc.resources but it will maybe help until we can fix the rest.
 

he_stheone64

Senior Member
Aug 1, 2008
5,033
10,991
Düsseldorf
I did that already (that was my first "dirty" attack :D), but then there are multiple errors about missing resources. Everything else is fixed, but renaming these folders is a pain.
 

fisha21

Senior Member
Nov 23, 2007
2,331
4,379
It`s not only the lockring, same issue with Rosie dock...

You will also have all xml`s decompiled with this workaround, but now compiling them successfully will be a bigger task. In any case now you have a base to start fixing issues, which is more likely then staring at a base of empty folders :D

Thanks for spending time on this, considering you don't even have a One X!

Just to confirm, the above approach works for .pngs and .9.pngs, thanks!

Now just trying to work out how to edit colors.xml. Since its in one of the hidden xml folders, I can't just drag and drop a recompiled edited version. I know resources .arsc contains the compiled xmls - is there any way to copy the info from the recompiled resources.arsc into the stock com.htc.resources.apk?
 

fernando sor

Inactive Recognized Themer
Sep 7, 2010
9,744
5,640
12
north of the wall
Just a reminder the apktool in the op is has the updated smali baksmali properties to decompile systemui. Just as instructed in the op make sure your resources are installed in apktool

Sent from my ADR6425LVW using xda premium
 
Last edited:
  • Like
Reactions: he_stheone64

he_stheone64

Senior Member
Aug 1, 2008
5,033
10,991
Düsseldorf
Thanks for spending time on this, considering you don't even have a One X!

Just to confirm, the above approach works for .pngs and .9.pngs, thanks!

Now just trying to work out how to edit colors.xml. Since its in one of the hidden xml folders, I can't just drag and drop a recompiled edited version. I know resources .arsc contains the compiled xmls - is there any way to copy the info from the recompiled resources.arsc into the stock com.htc.resources.apk?

That`s not possible, you need to fix the ERR folders first to compile resources.arsc

Anyway - I didn`t want to "highjack" this thread, so back to One S business :D

@ fernando - any positive results with the new merged apktool version (also on framework)?
 

fernando sor

Inactive Recognized Themer
Sep 7, 2010
9,744
5,640
12
north of the wall
That`s not possible, you need to fix the ERR folders first to compile resources.arsc

Anyway - I didn`t want to "highjack" this thread, so back to One S business :D

@ fernando - any positive results with the new merged apktool version (also on framework)?

Well I was able to decompile 4.0 sense com.htc.resources and I had not been able to do that with my apktool so huge thanks there. I haven't tried it on framework-res yet but i will today.

Sent from my ADR6425LVW using xda premium
 
  • Like
Reactions: he_stheone64

Rainbowbright081

Senior Member
Mar 20, 2011
264
47
Indiana
Fern do you know what xml file I would need to change to fix the text color and size on my widgets?
uploadfromtaptalk1337356704338.jpg


The red text, supposed to be white, and smaller... I have looked and looked to no avail... Google not my friend so much right now....


Sent from my HTC Sensation 4G using Tapatalk 2
 

fernando sor

Inactive Recognized Themer
Sep 7, 2010
9,744
5,640
12
north of the wall
Fern do you know what xml file I would need to change to fix the text color and size on my widgets?
View attachment 1068895


The red text, supposed to be white, and smaller... I have looked and looked to no avail... Google not my friend so much right now....


Sent from my HTC Sensation 4G using Tapatalk 2

Thanks for the donation bro.
I don't work with widgets much but my guess is if you can't find it some text is in m10 files. Hit the link in my sig. Those guys do a lot of widget work

Sent from my ADR6425LVW using xda premium
 

RegnierD

Inactive Recognized Contributor
Heya Fern! I haven't seen you since the OG DInc! (Back before I even knew what apktool was, lol!)

I've got some issues recompiling the SystemUI.apk from the Evo LTE, and I was wondering if you could provide a little guidance. I've used the resources from your OP, and got these errors when trying to build. (Ubuntu 12.04)

Code:
toddrick@Ubi:~/sdk/apktool$ ./apktool b SystemUI
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, -F, /tmp/APKTOOL6421459638993419441.tmp, -I, /home/toddrick/apktool/framework/1.apk, -I, /home/toddrick/apktool/framework/2.apk, -S, /home/toddrick/sdk/apktool/SystemUI/res, -M, /home/toddrick/sdk/apktool/SystemUI/AndroidManifest.xml]
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:193)
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:301)
	at brut.androlib.Androlib.buildResources(Androlib.java:248)
	at brut.androlib.Androlib.build(Androlib.java:171)
	at brut.androlib.Androlib.build(Androlib.java:154)
	at brut.apktool.Main.cmdBuild(Main.java:182)
	at brut.apktool.Main.main(Main.java:67)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, /tmp/APKTOOL6421459638993419441.tmp, -I, /home/toddrick/apktool/framework/1.apk, -I, /home/toddrick/apktool/framework/2.apk, -S, /home/toddrick/sdk/apktool/SystemUI/res, -M, /home/toddrick/sdk/apktool/SystemUI/AndroidManifest.xml]
	at brut.util.OS.exec(OS.java:87)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:191)
	... 6 more
Caused by: java.io.IOException: Cannot run program "aapt": java.io.IOException: error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
	at java.lang.Runtime.exec(Runtime.java:610)
	at java.lang.Runtime.exec(Runtime.java:483)
	at brut.util.OS.exec(OS.java:78)
	... 7 more
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
	at java.lang.ProcessImpl.start(ProcessImpl.java:81)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:468)
	... 10 more

Any suggestions? I'm trying to get rid of the lone menu software key for good, and change the value under home key for multi-press or whatever it's called from false to true, so that long-press home works for recent apps again until I finally decide where I want that to be mapped.
 

fernando sor

Inactive Recognized Themer
Sep 7, 2010
9,744
5,640
12
north of the wall
Hey regnier what's up ?
I would install resources from the evo rom and also did it decompile ok with no errors?

Sent from my ADR6425LVW using xda premium
 

RegnierD

Inactive Recognized Contributor
Hey regnier what's up ?
I would install resources from the evo rom and also did it decompile ok with no errors?

Sent from my ADR6425LVW using xda premium
Yup! I did:

Code:
apktool if (dir to SystemUI)
apktool if (dir to framework-res.apk)
apktool if (dir to com.htc.resources.apk)
apktool if (dir framework-htc-res.apk) (just in case)

Everything decompiled fine, giving the usual flag errors. I'm giving it a shot on Win7, because it looked like my Ubu terminal was rejecting some commands from apktool (I think because they didn't have ./ in front of the commands).

Edit: It was a no-go. I got apktool to build the apk after I specified a directory, but I had no statusbar after I compiled and pushed.

Is there a step I'm missing after I make the necessary edits to the xml file I'm after?
Code:
apktool d (dir to SystemUI)

(my edit to the navbar.xml)

apktool b SystemUI (dir to build)

If you have a spot of time, hit me up on G-Talk.

regnierdehrvand
 
Last edited:

fernando sor

Inactive Recognized Themer
Sep 7, 2010
9,744
5,640
12
north of the wall
Yup! I did:

Code:
apktool if (dir to SystemUI)
apktool if (dir to framework-res.apk)
apktool if (dir to com.htc.resources.apk)
apktool if (dir framework-htc-res.apk) (just in case)

Everything decompiled fine, giving the usual flag errors. I'm giving it a shot on Win7, because it looked like my Ubu terminal was rejecting some commands from apktool (I think because they didn't have ./ in front of the commands).

Edit: It was a no-go. I got apktool to build the apk after I specified a directory, but I had no statusbar after I compiled and pushed.

Is there a step I'm missing after I make the necessary edits to the xml file I'm after?
Code:
apktool d (dir to SystemUI)

(my edit to the navbar.xml)

apktool b SystemUI (dir to build)

If you have a spot of time, hit me up on G-Talk.

regnierdehrvand

Post your 1 and 2.apk (resource's) and your systemui. Let me rule a few things out first

Sent from my ADR6425LVW using xda premium
 

Top Liked Posts

  • There are no posts matching your filters.
  • 44
    Greetings

    i do not have have a one x but i have come up with a solution for the errors in apktool when recompiling framework-res.

    i have a rezound and have run sense 4.0 on my phone. the screen res is also very similar to the one x.

    there are four xmls in values that need to be rewritten.

    anims.xml
    layout.xml
    a small change in plurals.xml
    and raw.xml

    the change made in plurals has to be made in all the foreign language plurals if you want to keep the languages. you can however delete them if you like. the framework i am posting has the plurals fixed for all languages though.

    i am posting also my version of apktool which i have modified to properly smali htc apks.

    to begin.

    download the apktool linked here
    unzip and place the folder wherever you want on your computer.
    pull framework-res.apk and com.htc.resources.apk from your rom and place in the apktool folder

    open a command window to apktool. (right click on your apktool folder and hit shift at the same time. one of the options will be to open a command window.)

    type apktool if framework-res.apk hit enter
    then type apktool if com.htc.resources.apk hit enter

    now your needed dependencies are installed.

    type apktool d framework-res.apk framework hit enter.

    note im naming the out folder framework. you can name it anything you like.

    this will create a decompiled framework-res. i named the folder framework so there will be a framework folder in your apktool folder now.

    go to res/values anims.xml

    change this

    <anim name="htc_ime_decelerate_interpolator">@anim/zzz_htc_ime_decelerate_interpolator</anim>

    to this

    <item type="anim" name="htc_ime_decelerate_interpolator">@anim/zzz_htc_ime_decelerate_interpolator</item>

    go to res/values layout.xml

    change this

    Code:
    <layout name="htc_list_item_2text_2stamp">@layout/zzzz_htc_list_item_2text_2stamp</layout>
        <layout name="htc_list_item_2text_bright">@layout/zzzz_htc_list_item_2text_bright</layout>
        <layout name="htc_list_item_image_2text_image_bright">@layout/zzzz_htc_list_item_image_2text_image_bright</layout>
        <layout name="htc_list_item_imageicon_2text_2stamp">@layout/zzzz_htc_list_item_imageicon_2text_2stamp</layout>
        <layout name="htc_list_item_imageicon_text">@layout/zzzz_htc_list_item_imageicon_text</layout>
        <layout name="htc_list_item_separator">@layout/zzzz_htc_list_item_separator</layout>
        <layout name="keyguard_screen_device_unlock">@layout/zzzz_keyguard_screen_device_unlock</layout>
        <layout name="pin_keyboard">@layout/zzzz_pin_keyboard</layout>

    to this


    Code:
    <item type="layout" name="htc_list_item_2text_2stamp">@layout/zzzz_htc_list_item_2text_2stamp</item>
        <item type="layout" name="htc_list_item_2text_bright">@layout/zzzz_htc_list_item_2text_bright</item>
        <item type="layout" name="htc_list_item_image_2text_image_bright">@layout/zzzz_htc_list_item_image_2text_image_bright</item>
        <item type="layout" name="htc_list_item_imageicon_2text_2stamp">@layout/zzzz_htc_list_item_imageicon_2text_2stamp</item>
        <item type="layout" name="htc_list_item_imageicon_text">@layout/zzzz_htc_list_item_imageicon_text</item>
        <item type="layout" name="htc_list_item_separator">@layout/zzzz_htc_list_item_separator</item>
        <item type="layout" name="keyguard_screen_device_unlock">@layout/zzzz_keyguard_screen_device_unlock</item>
        <item type="layout" name="pin_keyboard">@layout/zzzz_pin_keyboard</item>

    go to res/values plurals.xml

    go to line 79

    change this

    %d of %d

    to this

    %1$d of %2$d

    now remember every foreign language plural needs that change or just delete them.

    go to res/values raws.xml

    change this

    <raw name="fallbackring_htc">@raw/zzzz_fallbackring_htc</raw>

    to this

    <item type="raw" name="fallbackring_htc">@raw/zzzz_fallbackring_htc</item>

    now when all of the plurals are changed or deleted ( do NOT delete the plurals in res/values. that has to be changed.)
    type apktool b framework hit enter. this will build your apk.

    here are the res/values xmls modded already to make this easy.

    download here replace the existing decompiled xmls with these.

    now when you decompile to make further changes you will find that three of the xmls

    anims.xml
    layout.xml
    raws.xml
    compile back to their original format so save the modified decompiled xmls

    this is the modified framework

    framework-res

    please post any issues
    3
    Very nice tutorial Fern, I'll be coming along as well. I like seeing some of the names in here, very comforting knowing there will be some really good devs on the ONE X. Look forward to some of the new stuff I can learn.
    2
    Can you send me the X com.htc? Then I can double check, whether I can also fix it. Maybe apktool creates other issues with the added xhdpi folders, but I can check that if you send me the stock file.

    Send from my One S
    2
    Great job ferno!!!!

    That sucks. One of our guys themed resources image by image running them all thru draw 9 patch tool One by one :eek::eek:

    I felt sorry for him :p

    Sent from my HTC One X using XDA

    Well I wouldn't say all of them, but quite a few :p

    I was able to add a lot of them to a different resources.apk and decompile.

    Sent from my HTC Flyer.

    I was just about to say do just that. lol. Throw the 9.png in a decodable resource.apk (or any apk for that matter) and decode. There is also a handy Mac and Linux tool for decoding 9.png :)
    2
    Thx and received - decompiled successfully, fixed all issues and now waiting to compile...

    TOUCHDOWN :D

    I will upload the apk later, I randomly changed a few color values to ICS blue, so you`ll see it worked all fine. System seems to work for all Sense 4.0 ICS com.htc.resources

    1. Fix Layoits.xml as described
    2. Delete zero_dummy_dimen in public.xml

    I will check later with stock com.htc.resources from One X, but I`m very confident I will see the same result ;)


    If only someone could fix bloody m.10`s - that is the sole reason I focus on mods atm, not on full Themes, since without having access to m.10 files Themes will not have the quality I need. Good news is, Sense 4.0 is visually so much better, then old versions.


    Edit: Here`s a new thread, that addresses this and more fixes

    http://xdaforums.com/showthread.php?p=25817188#post25817188