[DEV/GUIDE]Creating APKs for use with TMobile Theme engine

t3project

Senior Member
Jun 14, 2010
1,732
1,371
0
First of I want to say that I am not a developer. I don't have programming experience nor do I know a whole lot about this particular subject. I hope that sharing what I have found so far will help anyone else who wants to do something similar. With the help of voodoo55 I have successfully created and compiled APKs for use with the TMobile theme engine. Although this appears to be a great idea for the experienced developer because it will make themes cross device compatible it probably isnt going to be such a big hit with the normal joe blow themer such as myself for a few main reasons.

1. You have to be running linux and tapped into the CyanogenMOD github.
2. You're probably going to need to know a bit of xml coding (which I didnt when I started).
3. You're going to have to know how to decompile and edit .9 PNGs.
4. You're going to have to know how to compile APKs un linux as well​

None of these in themselves are all that complicated or hard for that matter, just tedious and very time consuming for the average themer. I am not going to get into specifics or xml code details here. As I am not a developer and dont know much about this stuff all I am going to do is tell you how these APKs function and what files need to be changed in order to compile them. Also, you'll find out the time consuming problem with compiling these APKs and how to fix it. Im just too lazy to sit here and manually fix hundreds of images.

Please remember these instructions are not very detailed but give a general idea on the direction you will need to take to make this happen. Also, for anyone who knows more about this than I do, please, feel free to correct me.


Step 1 - You are going to need to have a working linux distro running.​
Step 2 - You need to follow the instructions located here minus the last step to get the source from Cyanogen's github.​
Step 3 - Once #2 is complete and you have downloaded the source to the ~/android/system directory, you will find the current uncompiled source for the TMobile themes "Androidian" and "Cyanbread" in the ~/android/system/vendor/tmobile/themes directory.​
Step 4 - The experienced Dev would probably start completely from scratch here but I didn't so I'm not going to tell you how. As template, make a copy of the Cyanbread folder and renamed to your theme name.​
Step 5 - Here we are going to want to edit some files to make the compile possible with. In "your theme" directory there is a filed named Android.mk. In a txt editor you will need to change the following line:

Code:
LOCAL_PACKAGE_NAME := Cyanbread
to
Code:
LOCAL_PACKAGE_NAME := yourthemename
Step 6 - Edit the following lines in AndroidManifest.xml by replacing Cyanbread with your theme name.
Code:
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:pluto="http://www.w3.org/2001/pluto.html"
    package="com.tmobile.theme.Cyanbread"
    android:hasCode="false">

      <uses-feature android:name="com.tmobile.software.themes" />

    <theme
        pluto:themeId="Cyanbread"
        pluto:styleId="@style/Cyanbread"
        pluto:name="@string/theme_name"
        pluto:preview="@drawable/preview"
        pluto:author="@string/author"
        pluto:copyright="@string/copyright"
        pluto:wallpaperImage="@drawable/wallpaper"
        pluto:styleName="@string/style_appearance_name"
        pluto:ringtoneName="Shocking"
        pluto:ringtoneFileName="media/audio/ringtones/Shocking.mp3"
        pluto:notificationRingtoneName="Teleport"
        pluto:notificationRingtoneFileName="media/audio/notifications/Teleport.mp3">
Step 7 - Open up the res/values folder. There are two files in this particular template that need to be edited, strings.xml and themes.xml.

In the themes.xml you will need to change this line of code
Code:
<style name="Cyanbread" parent="@android:style/Theme" />
to this
Code:
<style name="yourthemename" parent="@android:style/Theme" />
and in the strings.xml you are basically doing the same thing by replacing "Cyanbread" everywhere with "yourthemename"
Code:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="app_name">Cyanbread Theme</string>
    <string name="theme_name">Cyanbread</string>
    <string name="style_appearance_name">Cyanbread</string>
    <string name="author">T-Mobile MSD</string>
    <string name="copyright">T-Mobile</string>
</resources>
it should look similar to this when edited
Code:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="app_name">youthemename Theme</string>
    <string name="theme_name">yourthemename</string>
    <string name="style_appearance_name">yourthemename</string>
    <string name="author">You are the author</string>
    <string name="copyright">there is no copyright on open source</string>
</resources>

Ok, so far this isn't to complicated but from here on out it gets a little more tricky for the average joe. Let me try to explain how these APKs work. Basically the xml files in the theme APK tells android to look in its own folders for, basically, substitute PNG images for the ones currently in the your framework and system/app packages on your phone. Pretty simple, no big deal. There are numerous xml files located in the various folders within the APK but I'm only going to talk about the two main ones need. In the res/xml there is a file named redirections.xml and android.xml. The redirections.xml basically tells the Tmobile theme picker thingy what other xml files to look at to find the source for the replacement PNGs. The main one being android.xml. Android.xml tells the OS on your phone what replacement PNGs to use for the theme. This will replace images that would normally be used from the framework-res.apk. There are other xml files in this directory as well, each one is correspondent to any APK in /system/app on your phone that you wish to theme. For instance com_android_systemui.xml will correspond to /system/app/SystemUI.apk. It works the same was that the android.xml file does and can be edited in the same way as well.

Hope that wasn't to confusing.

Step 8 - Now you will notice there are res/drawable-hdpi and res/drawable-mdpi folders in here as well. Here is where you will add new PNGs for your theme. Personally I deleted the entire contents of the folder and started over. Im not going to get into the specifics of what PNGs to replace as any themer should be ok with doing this. You can place images from any /system/app/*.apk as well but for now I am referring to the framework-res.apk. Once you replace your PNGs you are going to have to create an associated link in the android.xml.​


Please note: Any .9 PNGs you replace will HAVE, IT IS A MUST, to be decompiled and the borders edited correctly for the APK to compile correctly.


Step 9 - Open the android.xml file. Initially you will see lots of code but since you are starting over you will want to delete everything between these two lines.
Code:
<resource-redirections>

</resource-redirections>
Once this is complete we will now add the code you will need so it will find the PNG you replaced. For instance, if you placed an edited stat_sys_battery_40.png in the res/drawable-hdpi folder you are going to need to add this line of code the the xml file inbetween the <resource-redirections> code
Code:
<item name="drawable/stat_sys_battery_40">@drawable/frameworks_res_stat_sys_battery_40</item>
I hope you can see how the code corresponds to the PNG name as well. You can basically name the image anything you want as long as the code above is told to where to look.​

The same this would apply to any other xml file for their associated APKs as well.

Step 10 - Here you will want to edit the res/xml/redirections.xml file. You will see it has tons of stuff in it but again you will want to remove anything are not using. If you are only using say, the android.xml and the com_android_systemui.xml it would look similar to this:
Code:
<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:minSdkVersion="7"
        android:resource="@xml/android" />

    <package-redirections android:name="com.android.systemui"
        android:minSdkVersion="7"
        android:resource="@xml/com_android_systemui" />
</theme-redirections>
Step 11 - Now for the final test of whether or not you edited everything correctly you will need to compile the APK. Open a terminal window and type
Code:
 cd ~/android/system
and then type
Code:
make yourthemename

If you have edited everything correctly you APK will be compiled and can be found in the ~/android/system/out/target/product/supersonic/system/app folder. If it doesnt compile it will give you pretty specific errors in the terminal window that you could can go by to correct your problems.

And now for the BAD NEWS !!! The troubles I had while doing this was mainly with .9 PNGs. It seems that a ton of the .9 PNGs us normal themers use have been in some way corrupted d/t being edited incorrectly. Most of the borders are not done correctly. One of two things will happen: 1. They will not decompile correctly or 2. the will not compile correctly with the theme due to faulty editing. This is a simple fix but is extremely time consuming. And I, like most of us, simply don't have the time to fix each .9 I use in my themes for build each APK. Normal PNG changes are no problem however. I hope people will experiment with this as I have and will continue to do in my free time but for now I am going to stick to creating themes the old fashioned way. I do sincerely hope Cyanogen plans on placing his "UI Tweaks" section back into "CM Settings" as well for those of us who dont plan on building theme APKs.

Once again, I AM NOT a developer, so I probably couldn't answer any more advanced questions but feel free to ask. I'm sure there are plenty of people here who can. I just wanted to share my findings and what I did to make these APKs. The "Androidian" theme varies slightly if plan on using it as a template.
 
Last edited:
Hi! Thankk you so much for your tutorial, all works fine and apk is ok and properly installs on my N1, but if i try to upload the apk on market, it says me "The icon for your application is not valid. Please use a 48x48 PNG.".

Obviously, i checked twice my icons, and searched for a solutions on the net, and for the most of people with this problem it was due by a "\n" in the app name, and not from the icon. But i have not "\n" in my app name, and icons are right, so i can't figure out what is the error due to...

Can you give me some help?

Regards and sorry for my english! :)
 
Last edited:

mattyyey

Senior Member
Mar 28, 2010
204
88
0
Manchester
do you happen to know how this would be done on windows?

Currently I have the CyanBread template / source off t-mobiles github page and have a working SDK and eclipse plugin. I am capable of making unsigned or test signed apps and have compiled a few simple apps myself, which worked fine.

Now when I Run As or export unsigned app (as done previously) the theme manager say that the theme was NOT compiled correctly.

I have done this with an unedited version and a minimalist version containing only a few of the SystemUI and framework-res files and removed from the xml correctly, the images in use are the ones which came with the template and so should not be the problem.

I must say that I would not have been able to edit this much without your explainations, so TYVM! truely awesome! And when this works I have an awesome theme half developed , I'm itching to finish. :)

I've read something about a modified appt.exe to allow the theme manager to assign res images differently or something, this i cannot seem to find. or figure how to bypass. I understand that in linux, you can just pull the whole repository and get it as you stated above, but surely its possible in windows???

any and all help welcome! I'm no dev, but I'd love to be able to theme like this! no more update.zips!

------
p.s. I don't want to do it in Linux virtual box fyi, and even if i did repo/adb (in VM only) currently seem to be broken at my end.
 

mattyyey

Senior Member
Mar 28, 2010
204
88
0
Manchester
thanks alot for taking the time to reply, but i have read the first 2 links before and it only has instructions for getting the full repository in linux, as for the templates they are all quite similar, althought that one by haxzamatic is one of the "fullest" ones I've seen. This I'm sure is not the problem, as i can compile the template after importing it as a project in eclipse but it will NOT apply.

I have even made a signed apk and installed it off the SD, it installs fine, but wont apply.

I suppose i should get repo working in my linux box.... but i do think its silly the appt wasn't released for windows and linux.... any more advice? :confused:
 
Last edited:

trock79

Retired Recognized Developer
Jun 18, 2010
386
98
0
~/
I compiled my theme this morning, and it finished with no errors but when i go to install it doesn't work. The apk looks good, so Idk.
 

Haraldr Blaatand

Senior Member
Sep 30, 2010
117
10
0
I compiled my theme this morning, and it finished with no errors but when i go to install it doesn't work. The apk looks good, so Idk.
You have to be using the AAPT from T-Mobile git to support the theme resource IDs in resources.arsc. The stock AAPT will not generate the IDs expected by the theme manager.
 

t3project

Senior Member
Jun 14, 2010
1,732
1,371
0
If the instructions in this thread are followed everything works and applies correctly. I am getting the code from the cyan github.

Sent from my PC36100 using XDA App
 

trock79

Retired Recognized Developer
Jun 18, 2010
386
98
0
~/
If the instructions in this thread are followed everything works and applies correctly. I am getting the code from the cyan github.

Sent from my PC36100 using XDA App
That is fine if you want to work with the png's that are included with cyanbread theme, but I have more than what is included that theme and do not want to add all the commits just shy of a thousand more png's.
 

t3project

Senior Member
Jun 14, 2010
1,732
1,371
0
That is fine if you want to work with the png's that are included with cyanbread theme, but I have more than what is included that theme and do not want to add all the commits just shy of a thousand more png's.
you can use any png you want and as many as you want as long as you add the resource the the appropriate xml. they just have to be decompiled pngs and correctly edited for compiling. same thing goes for template them xml. just add the appropriate resource to the xmls and you can use whatever or howmany ever you want.

i did have a script that did this in about 2 seconds for you but i cant find it at the moment
 
Last edited:

worstenbrood

Senior Member
May 14, 2008
1,063
1,400
0
You dont need a linux box for it to compile, install the windows android sdk, eclipse + eclipse adt, git clone the androidian theme, create a new android project in eclipse, choose create from source and select the androidian folder, build and enjoy.
 
J

JudasLucifer

Guest
How can I just download the t-mobile bit (and gingerbread, or whatever is the barebones minimum for this)? Its downloading all the devices cyanogen supports, and thats just a waste of my time/disk space/internet connection (which is particularly slow)
 

7.7.7.7.7.7.7

Senior Member
Oct 22, 2011
175
109
0
Tanah Sunda
items name

This is about /res/xml/android.xml.

how to do so that we can know where the drawable position located? I'm confused what the name of the image that I would change.

examples where the position of the image and name in the /res/xml/android.xml.

 

Attachments

Last edited: