yashsingh1/xdaforums huggingface dataset:
[Android Themes] dully79:
You dont have a redirections.xml in the xml folder.

Refer to the the guide for how to add them under the "Redirection" heading.

You should end up with 32 referenced packages in the xml

Here is a small example:

<?xml version="1.0" encoding="utf-8"?>
<theme-redirections
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pluto="http://www.w3.org/2001/pluto.html">
<package-redirections android:name="android" android:resource="@xml/android" android:minSdkVersion="15" />
<package-redirections android:name="com.android.calculator2" android:resource="@xml/com_android_calculator2" android:minSdkVersion="15" />
<package-redirections android:name="com.android.contacts" android:resource="@xml/com_android_contacts" android:minSdkVersion="15" />
<package-redirections android:name="com.android.deskclock" android:resource="@xml/com_android_deskclock" android:minSdkVersion="15" />
<package-redirections android:name="com.android.mms" android:resource="@xml/com_android_mms" android:minSdkVersion="15" />
<package-redirections android:name="com.android.phone" android:resource="@xml/com_android_phone" android:minSdkVersion="15" />
<package-redirections android:name="com.android.settings" android:resource="@xml/com_android_settings" android:minSdkVersion="15" />
<package-redirections android:name="com.android.systemui" android:resource="@xml/com_android_systemui" android:minSdkVersion="15" />
</theme-redirections>

The xmls in your folder look like the dev has kept the original package name structure intact, just edit the "_" to "." when adding the syntax

Here's an example using a line of code from above:

<package-redirections android:name="com.android.contacts" android:resource="@xml/[COLOR="Red"]com_android_contacts[/COLOR]" android:minSdkVersion="15" />

<package-redirections android:name="com.android.contacts" android:resource="@xml/[COLOR="red"]com_pandora_android[/COLOR]" android:minSdkVersion="15" />

<package-redirections android:name="[COLOR="red"]com_pandora_android[/COLOR]" android:resource="@xml/com_pandora_android" android:minSdkVersion="15" />

<package-redirections android:name="[COLOR="red"]com.pandora.android[/COLOR]" android:resource="@xml/com_pandora_android" android:minSdkVersion="15" />

This references the "com_pandora_android.xml" you have in the xml folder.
[Android Themes] rebj2007:
Can you give a easier tutorial? i don't have enough knowledge about java. thanks
[Android Themes] dully79:
Adding packages to redirections.xml

It's not java, i dont have a clue about java.

I cant describe it any easier than above.

Open attached to redirections.txt, copy and paste it into a new page in notepad++ and save it as "redirections.xml".

Copy a line of the existing code and paste it into a new line using the xml names in your xml folder, like i have done below.

Example;

Pandora=com_pandora_android

[COLOR="SeaGreen"]#Copy and paste a line of code into a new empty line:[/COLOR]
<package-redirections android:name="com.android.contacts" android:resource="@xml/com_android_contacts" android:minSdkVersion="15" />
[COLOR="SeaGreen"]#Change the xml reference name to the xml name you want to add:[/COLOR]
<package-redirections android:name="com.android.contacts" android:resource="@xml/[COLOR="Red"]com_pandora_android[/COLOR]" android:minSdkVersion="15" />
[COLOR="SeaGreen"]#Copy across the xml reference name to the package name:[/COLOR]
<package-redirections android:name="[COLOR="red"]com_pandora_android[/COLOR]" android:resource="@xml/com_pandora_android" android:minSdkVersion="15" />
[COLOR="SeaGreen"]#Replace underscores "_" with full stops "." :[/COLOR]
<package-redirections android:name="[COLOR="red"]com.pandora.android[/COLOR]" android:resource="@xml/com_pandora_android" android:minSdkVersion="15" />

I cannot make it any easier than that.
[Android Themes] rebj2007:
when i'm done what will i do next?
[Android Themes] dully79:
recompile, sign, install and apply
[Android Themes] rebj2007:
i got an error i can't recompile.
[Android Themes] dully79:
Thanks, thats very helpful.
[Android Themes] dully79:
Please remove all that text or use hide tags.

It tells you the problem in the log.

Wed 08/14/2013 -- 9:45:01.13|
--------------------------------------------------------------------------
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
I: Baksmaling...
I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Ralph\apktool\framework\1.apk
I: Loaded.
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
[COLOR="Red"]C:\Users\Ralph\Desktop\APK-Multi-Tool\other\..\projects\unsignedSampleTheme-sign
ed.apk\res\xml\redirections.xml:35: error: Error parsing XML: not well-formed (i
nvalid token)[/COLOR]

You have an error code in the redirections.xml @ line 35.
[Android Themes] rebj2007:
Yes, i will only use it for personal use. I installed and make it work but i'm having FC's.
[Android Themes] dully79:
Then you have problems with the images in your theme. You'll have to try and narrow it down by comparing them with the original apk images.

Good luck
[Android Themes] amadovi43:
this is the apk i ported over.

https://www.dropbox.com/s/i6wl9sjs5dpt85n/newxblue.apk

now since this is for a sgs4 i need touchwiz rediretions

1)what do i need from the phone.apk to add into my theme apk

2)where do i find the original source or file i plan to theme

3)am i modifing android.xml or am i creating a new xml

4) do i need to add new png or can i use some that are already in the theme

5) drawables do i do anything with that

thank you

---------- Post added at 01:48 PM ---------- Previous post was at 01:33 PM ----------

so i saw this but again i want to learn how it works. i want to be able to help people when they get stuck. or fix something on my own or add etc

thanks for the files for the mean time

ps will it work for 4.2.2?
[Android Themes] dully79:
Creating an apk redirection xml

You will need to create a redirection xml for the apk you want to theme. "com_android_phone.xml"

Creating a package redirection xml:

Download my tool from here- http://xdaforums.com/showthread.php?t=2312681 and extract it somewhere suitable.

Decompile your *apk, in this scenario it's SecPhone.apk. You can find this in your ROM.zip in system/app.

Go into the res folder and type in the search window ".png". This will show all the png's in the drawable folders.

Select all from the search results window and

copy

them into the resources folder of the extracted XML Generator folder.

When prompted answer no or yes to replace, it makes no difference. The reason being you have multiple images with the same name.

Download and install Bulk rename utility- http://www.bulkrenameutility.co.uk/Main_Intro.php

Open bulk rename and navigate to the XML Generator/Resouces folder. Where you copied your images.

In the window that says add(7) >Prefix enter "com_android_phone_" Dont forget the underscore at the end!!

Click actions tab>select all and hit enter. All the images in the resources folder will now have a prefix.

Open up the XML Generator wrapper.bat

Choose option 1

Type "com_android_phone" and press enter, then "y" to confirm.

Choose option 2 and select "y" to use the same package name.

Select option 3 to create and follow the prompts.

Now you have an xml with every single png referenced from SecPhone.

You can copy the generated com_android_phone.xml into the xml folder and add a reference to it in the "redirections.xml" by adding in the following code:

<package-redirections android:name="com.android.phone" android:resource="@xml/com_android_phone" android:minSdkVersion="15" />

If the reference already exists then open up both "com_android_phone" xmls and copy the code from the ghenerated xml into the existing and save.

Now you are able to add/modify anything you like with drawable.png's from SecPhone as long they have the "com_android_phone" prefix in their name, example- "com_android_phone_ic_launcher".

Just follow step 7 above to bulk rename.

What you add is up to you. You will need to compare the png's from the theme to the SecPhone.apk and see if you are missing anything.

I'd recommend finding a theme that changes SecPhone and see what changes that dev made to give you an idea.
[Android Themes] amadovi43:
thank you so much i think i can work off this now.

i can finaly sleep its been driving me crazy not knowing how this works

---------- Post added at 02:29 PM ---------- Previous post was at 02:21 PM ----------

to be clear frameworks_res redir. go in android.xml?

what about two frameworks.apk i would have tor create a new xml and add it to the redir
[Android Themes] dully79:
No problem. It's daunting when you dont know but easy when you do.:)

There is a little workflow in the OP that describes adding redirections for Gmail icon.

All you are doing is re-routing resources from the original apk to your theme.apk

A bit like forwarding a letter from one address to another.

redirections xml - This is top of the tree and redirects the apk by referencing the original package name and applicable xml in the xml folder:

Basically it tells the xtheme engine to overlay SystemUI with the resources that are defined in the xml called "com_android_systemui.xml" in the xml folder.

<package-redirections android:name="[COLOR="Red"]com.android.systemui[/COLOR]" android:resource="@[COLOR="RoyalBlue"]xml/com_android_systemui[/COLOR]" android:minSdkVersion="15" />

com_android_systemui.xml- This tells the XTheme engine what to redierct. This example is telling the engine to look in the drawable folder and use our new "stat_airplane_on" toggle instead of the original "stat_airplane_on"

<item name="[COLOR="Red"]drawable/stat_airplane_on[/COLOR]">@[COLOR="RoyalBlue"]drawable/com_android_systemui_stat_airplane_on[/COLOR]</item>

Now all we need is to add the "stat_airplane_on" toggle in the drawable folder

They can go in any file name you want as long as they contain the correct reference. Some people use "frameworks_res", i use "android"

If you talking about TWframework.apk you need to create an xml for that too.
[Android Themes] amadovi43:
AHHHHHHH! BRAIN OVER LOADS.

But I get it now. I mean it was a puzzle for me a second ago. But I had no idea what to do with the pieces. Now I think that I can do a bit more and grasp the idea of what this does. I feel xposed is over looked but it's so awesome with things like xthemes. Again thanks so much I will have more questions. Going to bed clear my head. Get back to this project.
[Android Themes] amadovi43:
So in my theory from what you have told me is:

I can grab the drawables from secPhone.apk and add them to my theme.apk into /res/ since some of the tw png are going to be missing. right? and can i just select all drawables from secPhone.apk or is there some that don't matter me bringing over.

i say this cuz i see some redirects start with tw_****
[Android Themes] dully79:
Yes you can add any drawable from SecPhone as youve added all the drawable references in the com_android_phone.xml

You can add all the images but it will add unnecessary bloat to your theme, or you can try and narrow it down to just the images you want to use,e.g dialer backgrounds.
[Android Themes] amadovi43:
what about duplicate lines of code in the xml? does it matter can i leave theme or should i find a way to remove any duplicate text
[Android Themes] dully79:
Remove them.

http://stackoverflow.com/questions/3958350/removing-duplicate-rows-in-notepad

I recommend sorting the lines in order regardless as its easier to follow.

Also as all the phone apk's have the same packaqge name (com_android_phone) regardless of the apk name- Phone (AOSP), SemcPhone (Sony), SecPhone (TW). I add a prefix to seperate the images from one another in the referenced code in the com_android_phone.xml and the images like so:

<item name="drawable/btn_onoff_indicator_on">@drawable/[COLOR="Red"][B][U]semc_[/U][/B][/COLOR]phone_btn_onoff_indicator_on</item>
<item name="drawable/dialer_press">@drawable/[COLOR="red"][B][U]tw_[/U][/B][/COLOR]com_android_phone_dialer_press</item>

This makes it easier and cleaner to know which image comes from which apk.
[Android Themes] amadovi43:
Speaking of images how do i know what folder to take png from. xhdpi is for hi-def screens and so is hdpi but theres some odd drawables like

drawable-iw-sw359dp-xxhdpi

drawable-mcc450-mnc5-sw359dp-xxdpi

should i just pull from xhdpi and hdpi?
[Android Themes] dully79:
You may have to copy both, it depends what they contain. I cant say for sure as i dont have the SGS4. You will however have to use xhdpi

The SGS4 is 1080 x 1920 pixels, 5.0 inches (~441 ppi pixel density)

xhdpi 320dpi > 480dpi
[Android Themes] amadovi43:
ok thats what i though i'm just testing the phone apk at the moment once i get this down can start theming my own stuff.

this should also be helpfull for cm10 theme engine right?
[Android Themes] dully79:
Once you get into it you'll be fine and the walls will start crumbling.

Yeah, it works for CM themes. Ive ported a few themes, they dont work as well as the original but XTheme is limited compared to theme chooser so dont get your hopes up unless your using AOSP.
[Android Themes] amadovi43:
yeah i want to make one theme and then see if i like it or if its too much work lol

but i know some things dont port over. but its a learning experience for me
[Android Themes] Thomas_BA:
Very interesting thread and tutorial in the OP.

Does anybody has the redirection needed for Motorola RAZR XT910 Stock JB 4.1.2.

Want to port a theme for my phone.

Thanks
[Android Themes] dully79:
Your the first ive seen with a moto, you'll probably have to add them yourself.:good:
[Android Themes] Thomas_BA:
Well than, lets get to work ;) I think i was joking. Not enough knowledge and time to do so.

Perhaps some time somebody can do so for Moto. Seams everybody is making themes Samsung ans Xperia :(
[Android Themes] SXUsr:
I spent the day yesterday having a play with it but found it a little disappointing. Without being able to add styles to make apps dark and a few other little issues I'll stick to direct apk modding for the time being.
[Android Themes] dully79:
Thats because people have bothered to create the redirections needed and not wait around for others to do it for them.:good:

Yep, no styles blows, but being stuck on a stock ROM, its still better than having nothing.

If i want something dark ill just search for the inverted apk.
[Android Themes] Okluzhion:
Just please don't murder me if I'm missing something obvious here. My back is killing me, my vision is blurry, no beer for me, and it's already late, so my brain function is lowered by 90%, lol. Excuse my stupidity in advance.

I've been trying to compile a theme for hours now. This is what I'm getting:

java version "1.7.0_25"

Java(TM) SE Runtime Environment (build 1.7.0_25-b17)

Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)

I: Checking whether sources has changed...

I: Checking whether resources has changed...

I: Building resources...

C:\Users\Sara\Downloads\APK-Multi-Tool\other\..\projects\SampleTheme.apk\res\val

ues\styles.xml:121: error: Error: Dimension types not allowed (at 'android:textA

ppearanceAutoCorrectionSuggestion' with value '16.0dip').

Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.Androl

ibException: brut.common.BrutException: could not exec command: [aapt, p, --min-

sdk-version, 14, -F, C:\Users\Sara\AppData\Local\Temp\APKTOOL3863070482510873411

.tmp, -0, arsc, -I, C:\Users\Sara\apktool\framework\1.apk, -S, C:\Users\Sara\Dow

nloads\APK-Multi-Tool\other\..\projects\SampleTheme.apk\res, -M, C:\Users\Sara\D

ownloads\APK-Multi-Tool\other\..\projects\SampleTheme.apk\AndroidManifest.xml]

at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)

at brut.androlib.Androlib.buildResources(Androlib.java:283)

at brut.androlib.Androlib.build(Androlib.java:206)

at brut.androlib.Androlib.build(Androlib.java:176)

at brut.apktool.Main.cmdBuild(Main.java:228)

at brut.apktool.Main.main(Main.java:79)

Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not

exec command: [aapt, p, --min-sdk-version, 14, -F, C:\Users\Sara\AppData\Local\

Temp\APKTOOL3863070482510873411.tmp, -0, arsc, -I, C:\Users\Sara\apktool\framewo

rk\1.apk, -S, C:\Users\Sara\Downloads\APK-Multi-Tool\other\..\projects\SampleThe

me.apk\res, -M, C:\Users\Sara\Downloads\APK-Multi-Tool\other\..\projects\SampleT

heme.apk\AndroidManifest.xml]

at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav

a:357)

at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)

... 5 more

Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sd

k-version, 14, -F, C:\Users\Sara\AppData\Local\Temp\APKTOOL3863070482510873411.t

mp, -0, arsc, -I, C:\Users\Sara\apktool\framework\1.apk, -S, C:\Users\Sara\Downl

oads\APK-Multi-Tool\other\..\projects\SampleTheme.apk\res, -M, C:\Users\Sara\Dow

nloads\APK-Multi-Tool\other\..\projects\SampleTheme.apk\AndroidManifest.xml]

at brut.util.OS.exec(OS.java:89)

at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav

a:355)

... 6 more
[Android Themes] Rycon33:
delete that line in styles.xml under the folder /res/values that's having error - android:textA

ppearanceAutoCorrectionSuggestion

And I think another error will comeout after that, you can actually delete the whole content of styles.xml entirely iirc coz it won't stick anyway.
[Android Themes] Okluzhion:
I've completely overseen that line. Sorry for troubling you with an obvious problem, and thanks for helping.

Sent from my Xperia Z

Edit:

Sorry to bother you again, but I have some questions concerning Sony devices. I can't seem to get switch buttons nor Settings.apk (and possibly other apps) to theme. In some ported themes switch buttons are themed, but oversized. I've seen ported apps that are working properly ([almost] everything is themed) on other devices, but on my Z even with the redirections, a lot is left untouched (stock look). Do you happen to know how to get these things working? Could the problem be in Xperia Z being xxhdpi device?

Also, with some themes, this is what happens in notifications (not aligned properly)

Edit2:

Nvm, I found a theme that's working almost 100% on Z, I'll try to analyze it to see what I need to do to make other ports work.
[Android Themes] Rycon33:
[MENTION=4206680]sunbriel[/MENTION]

Based from your screenshot, I have read many posts even on the original themes, they also have that misalignment issue especially on xxhdpi(1080p hi-res) devices like Z

For the Settings icons, you may try to take look inside at dully's Simplicity theme, there you'll find the "settings_header.xml" redirection and you will learn how to set it up based from his setup.

For switch buttons, this is how I do it:

In android.xml(add the below code):

<item name="drawable/semc_switch_inner_holo_dark">@drawable/[COLOR="Red"]semc_switch_inner_holo_dark[/COLOR]</item>
<item name="drawable/semc_switch_inner_holo_light">@drawable/[COLOR="red"]semc_switch_inner_holo_light[/COLOR]</item>
<item name="drawable/semc_switch_track_holo_dark">@drawable/[COLOR="red"]semc_switch_track_holo_dark[/COLOR]</item>
<item name="drawable/semc_switch_track_holo_light">@drawable/[COLOR="red"]semc_switch_track_holo_light[/COLOR]</item>
<item name="drawable/semc_switch_bg_on_disabled_holo_light">@drawable/frameworks_res_switch_bg_disabled_holo_light</item>
<item name="drawable/semc_switch_bg_on_disabled_holo_dark">@drawable/frameworks_res_switch_bg_disabled_holo_dark</item>
<item name="drawable/semc_switch_bg_on_holo_light">@drawable/frameworks_res_switch_bg_holo_light</item>
<item name="drawable/semc_switch_bg_on_holo_dark">@drawable/frameworks_res_switch_bg_holo_dark</item>

then put these xml files(the 4 semc*** thing from the above) in theme's "/res/drawable" folder
[Android Themes] Okluzhion:
[MENTION=4023029]Rycon33[/MENTION]

Thanks for the info and help! I will look into it tomorrow asap. :)
[Android Themes] dully79:
[MENTION=4206680]sunbriel[/MENTION],

What theme is working well, i'll have to check it out and see if i can improve mine.
[Android Themes] Okluzhion:
I'm currently using Simplex theme that I found in XT forum (actually, have seen you in that thread). Systemui is themed properly (no alignment/missing elements issue), pop-up windows and menus are themed, etc. Everything seems to be fine even on XZ, an xxhdpi device.

I've tried your Simplicity xTheme, but it seems to be incompatible with xxhdpi, as you stated. Some elements are downsized, some are pixelated, toast notifications are stretched (could fit two lines of text in one line notif). I really like how it looks in the screenshots, though. I didn't realize that much can be achieved with xTheme.

Sent from my Xperia Z
[Android Themes] dully79:
That's more than likely using my redirections.

You could try deleting the xxhdpi folder from Simplicity and see if that runs better for you.

I found this which is interesting in regards to using xxhdpi resources:

http://stackoverflow.com/questions/17364394/android-graphics-for-xxhdpi
[Android Themes] Okluzhion:
I know it is, I'm only trying to understand what I need to do to maximize the number of ported elements. Either the themes I'm trying to port are not well written (also, I noticed none had redirections.xml) or I have to add/adjust extra drawable redirections. I'll look into your theme when I get to my laptop again, I'm currently tied to my phone.

Edit:

About the whole xxhdpi thing. Haven't come across any theme that supports xxhdpi, but xhdpi seems to play nice with Z. The difference in graphics is unnoticeable on the device itself, the only way you could see the quality difference is to take a screenshot and then view it in full size on PC screen. Honestly, this whole xxhdpi is kind of an overkill. There is no need to include xxhdpi resources as the device will just fall back to xhdpi if there isn't xxhdpi present in app/theme. And like I said, seeing the difference on a 5" screen between the two is pretty hard.

Sent from my Xperia Z
[Android Themes] dully79:
Ok, if it is using my redirections i have no need to look into it.:)

If you want to do it onboard:

Copy apk to sdcard.

Uninstall theme.

Rename copied apk to zip.

Unzip and delete meta-inf and drawable-xxhdpi. I use Zarchiver from play store.

Zip backup and rename apk.

Sign and install. I use Zipsigner.

Prosper.:good:

I think i'm going to create a general redirections.xml with a sh1t load of packages included so folk just need to add their referenced package.xmls.

It would be nice if their was a tool that created the redirections.xml for you.
[Android Themes] Okluzhion:
Ah, I'm not 100% sure he's using only your redirections, so you can take a look.

I use ZArchiver and Zipsigner too, pretty useful apps. The only thing is that unpacking archives is kinda slow on phones in general :D

Sent from my Xperia Z
[Android Themes] dully79:
I'll have a mooch. Who ported it?

Yep, especially nearly 50 MB.:eek::(
[Android Themes] Okluzhion:
mcsqwizzys98 ported it.

I'm getting parsing error. I guess I'll have to do it over the laptop after all ^^'

Sent from my Xperia Z
[Android Themes] StaticMaal:
I got failed to apply theme. I tired to port this theme for TouchWiz http://xdaforums.com/showthread.php?t=1684743
[Android Themes] xxxMADxxx:
Guys for "com.android.systemui=16" the "16" its meant android sdk version of our rom right?
[Android Themes] dully79:
I'm afraid i need more information than that, but i'm going to guess you dont have a redirections.xml in the xml folder. Read the second post.

Thats the sdk your targeting.