Jump to content

Creating custom themes by modifying framework-res.apk


Recommended Posts

Guest McSpoon
Posted

It's possible to modify the graphics in /system/framework/framework-res.apk to create your own theme. Here is a quick overview of how you can do it.

Within framework-res.apk there are lots of graphics in the /res/drawable/ folder that are commonly used by Android. Now .APK files are essentially just .ZIP files so you can open them with WinZip, WinRAR, etc. Depending on which type of software you're using, you may even be able to click on one of the enclosed .png files so that the image loads up in your favourite art package, make your changes, and save it - sometimes all this can be done without manually unpacking and repackaging the zip file (depending on the software you use).

After you've finished modifying framework-res.apk you need to 'sign' it. Applications are signed to protect them from being hacked. If you modify an .apk file without signing it then Android may suspect the file has been compromised and reject it. There are various tools developed by the modding community to sign .apk files. Some are more difficult to setup than others. Does anyone have any recommendations for good ones?

When transferring framework-res.apk to your device you'll have to temporarily remount the system partition with write access. It's generally safer to do this in recovery mode because then the system isn't running. The following adb command will remount the system partition allowing you to replace the file.

adb shell mount -o rw /dev/block/mtdblock1 /system

Now you can push your modified framework-res.apk onto your device, eg.

adb push framework-res.apk /system/framework/

Admittedly this post is just a general overview of the process. There are some great tutorials in the Android modding community that explain it far better. It would be great to see some custom themes specifically designed for the Pulse.

Posted (edited)

hey there

i have vanilla 1.7 on my pulse, tried to replace the framework-res.apk with this one http://www.jbthemes.com/metamorph/BlackBar...14.1-signed.zip

but the system didn't boot, must be cause it was for cm rom

i'll go find about signing the framework-res

found this http://forum.xda-developers.com/showthread.php?t=549309

and this http://lulachronicles.blogspot.com/2009/11...e-and-sign.html

Edited by intlrc
Guest John Hamelink
Posted

I have the same issue, I modify the apk, repackage and sign it (I'm using the nautilus right-click sign method), but android doesn't get past the "android" bootsplash. DDMS says the following:

02-07 13:45:17.669: INFO/Zygote(1299): Preloading classes...

02-07 13:45:22.189: WARN/ResourceType(1299): Unable to get buffer of resource asset file

02-07 13:45:22.189: WARN/dalvikvm(1299): Exception Landroid/content/res/Resources$NotFoundException; thrown during Landroid/text/AutoText;.<clinit>

02-07 13:45:22.189: WARN/dalvikvm(1299): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)

I'm not sure where to go from here.

Guest BigBearMDC
Posted

That looks like the images are saved in a special format or something like that.

Maybe the size of the image (in byte) is saved as the size of the buffer.

Greetings,

BigBear

Guest John Hamelink
Posted (edited)
That looks like the images are saved in a special format or something like that.

Maybe the size of the image (in byte) is saved as the size of the buffer.

Greetings,

BigBear

Interestingly, If you look at the filesize of the contents of my modified apk:

assets - 250.3kb

META-INF - 165.8kb

res - 1.4mb

AndroidManifest.xml - 31.4kb

resources.arsc 1.0mb

and those of the original:

assets - 242.6kb

META-INF - 165.8kb

res - 1.4mb

AndroidManifest.xml - 31.4kb

resources.arsc 1.0mb

There is a neglegable difference (yes, I know that this matters). However, if you look at the archives themselves:

Modified - 1.6MB

Unmodified - 2.5MB

What is going on here? Is there something hidden inside the archive its self?

Also, replacing the original APK fixes the boot freeze every time.

Edited by John Hamelink
Guest BigBearMDC
Posted (edited)

I guess that the pictures have a lot of hidden metadata that gets erased if you copy another image into the archive.

Maybe have a look at the images using a HEX editor and have a look at the metadata section of the file.

It could also be that the image is linked with some other files that aren't 'visible' and that those files get erased.

Greetings,

BigBear

Edited by BigBearMDC
Guest John Hamelink
Posted (edited)

Yes, there is definitely something wrong with my archives, as I just repackaged the original apk without making any modifications, and it is 1.6mb in size, and I also get the same error.

I guess that the pictures have a lot of hidden metadata that gets erased if you copy another image into the archive.

Maybe have a look at the images using a HEX editor and have a look at the metadata section of the file.

It could also be that the image is linked with some other files that aren't 'visible' and that those files get erased.

Greetings,

BigBear

will do.

Edited by John Hamelink
Guest BigBearMDC
Posted

Its difficult, but try to copy your image into the archive using a HEX editor.

Thus you can be sure not to delete other files or informations that are stored in the archive.

Maybe I'll have a look at that later.

Greetings,

BigBear

Guest John Hamelink
Posted
Its difficult, but try to copy your image into the archive using a HEX editor.

Thus you can be sure not to delete other files or informations that are stored in the archive.

Maybe I'll have a look at that later.

Greetings,

BigBear

I have absolutely no idea how to do that, however what I did just do was to make a hexdump of the unmodified and re-signed (that's the only thing that's changed) apks and then run a diff on them:

hexdump -C framework-res_old.apk > unmodified

hexdump -C signed-framework-res_old.apk > modified
Then use Meld Diff viewer to see the comparison. The result was that they look completely different, apart from 1 line:
00000020  54 41 2d 49 4e 46 2f 4d  41 4e 49 46 45 53 54 2e  |TA-INF/MANIFEST.|

Is this to be expected?

Guest BigBearMDC
Posted (edited)

Copying the picture using a HEX editor should work fine.

I extracted the framework-res.apk and opened btn_lock_code_touched.png with the HEX editor.

Then I opened the framework-res.apk it self with a HEX editor and searched for the last

160 Bytes of the image file. And i found them :D

So you can just open an image that you want, copy the whole Bytestream with a HEX editor, extract the framework, open the file you want to override with a hex editor, copy the first 160 Bytes and the last 160 Bytes of that image, open the framwork with an HEX editor, select the whole crap between the first 160 Bytes and the last 160 Bytes of the image you want to replace and just paste the Bytestream of youre original Image there ;)

Maybe I'll write an application (for Windows) that automatically does that. But I'm using C# so you would need to install .NET framework.

EDIT:

Is someone interseted in such an application?

Greetings,

BigBear

Edited by BigBearMDC
Guest John Hamelink
Posted (edited)
Copying the picture using a HEX editor should work fine.

I extracted the framework-res.apk and opened btn_lock_code_touched.png with the HEX editor.

Then I opened the framework-res.apk it self with a HEX editor and searched for the last

160 Bytes of the image file. And i found them :(

So you can just open an image that you want, copy the whole Bytestream with a HEX editor, extract the framework, open the file you want to override with a hex editor, copy the first 160 Bytes and the last 160 Bytes of that image, open the framwork with an HEX editor, select the whole crap between the first 160 Bytes and the last 160 Bytes of the image you want to replace and just paste the Bytestream of youre original Image there ;)

Maybe I'll write an application (for Windows) that automatically does that. But I'm using C# so you would need to install .NET framework.

EDIT:

Is someone interseted in such an application?

Greetings,

BigBear

Such an application would be awesome! Perhaps you could use mono to make it compatible with multiple OSs? I'd be happy to help you test on Linux and Wine :D

Edited by John Hamelink
Guest HunteronX
Posted

I think that the metadata you're talking about is to do with nine patch images - here's a link about them.

http://developer.android.com/guide/topics/....html#ninepatch

I tried to use a hero mod, replacing /drawable/ files in the framework-res.apk, as well as cyanogen animations from a metamorph zip into /anims/, but it didn't work for me either, as the phone would boot to the flashing android logo, but I could unlock my phone, while still seeing the logo.

I haven't got any further than this.

Hopefully, this nine patch image information will help. ;)

Guest David Horvath
Posted

I have edited this, and this works. There are pictures changed, size is different, but works perfectly. Had to make place for it, i deleted mp3's.

Why i'm not allowed to upload files?

Guest John Hamelink
Posted
I have edited this, and this works. There are pictures changed, size is different, but works perfectly. Had to make place for it, i deleted mp3's.

Why i'm not allowed to upload files?

Upload them to mediafire.com

Guest David Horvath
Posted
Copying the picture using a HEX editor should work fine.

I extracted the framework-res.apk and opened btn_lock_code_touched.png with the HEX editor.

Then I opened the framework-res.apk it self with a HEX editor and searched for the last

160 Bytes of the image file. And i found them :(

So you can just open an image that you want, copy the whole Bytestream with a HEX editor, extract the framework, open the file you want to override with a hex editor, copy the first 160 Bytes and the last 160 Bytes of that image, open the framwork with an HEX editor, select the whole crap between the first 160 Bytes and the last 160 Bytes of the image you want to replace and just paste the Bytestream of youre original Image there ;)

Maybe I'll write an application (for Windows) that automatically does that. But I'm using C# so you would need to install .NET framework.

EDIT:

Is someone interseted in such an application?

Greetings,

BigBear

Please make it cross-platform i dont have and i dont want to have windows. (In the world of freedom, who needs Gates and Windows?)

With mono and .net you can easily write one natively. Python or Java maybe? You can work with native C code as well :D

Guest BigBearMDC
Posted

First, I'll write it for Windows, because I'm used to it.

I never wrote something before for Linux, but for Java.

If it works for Windows I'll upload it. Then I'll try to make it in Java ;)

Greetings,

BigBear

Posted
See attachment.

but the status bar is in the framework-res.apk not the launcher bar i guess..

Guest John Hamelink
Posted
First, I'll write it for Windows, because I'm used to it.

I never wrote something before for Linux, but for Java.

If it works for Windows I'll upload it. Then I'll try to make it in Java :D

Greetings,

BigBear

Great news ;)

Guest David Horvath
Posted
but the status bar is in the framework-res.apk not the launcher bar i guess..

I modified the handle image of the launcher. It is painfully awful ;)

Guest McSpoon
Posted
Modified - 1.6MB

Unmodified - 2.5MB

What is going on here? Is there something hidden inside the archive its self?

Regarding this issue, I'm not sure what that happens but the best way to avoid it is - don't unpack and repackage the zip file. Try to make your modifications all from within your zip software if possible.

Posted

I found this problem, the way I did the phone.apk and res.apk was to use winrar, extract only the images I wanted to change, then drag the replacement image back into winrar.

One thing I did notice is if you want to Push the .apk you may have to resign, if you make a custom update.zip with just the themed .apk's in it you dont need to resign the apk.

Guest David Horvath
Posted
I found this problem, the way I did the phone.apk and res.apk was to use winrar, extract only the images I wanted to change, then drag the replacement image back into winrar.

One thing I did notice is if you want to Push the .apk you may have to resign, if you make a custom update.zip with just the themed .apk's in it you dont need to resign the apk.

I'm using the file-roller of Ubuntu, and i was just overwriting files, not extracting/re-creating archives. It worked out.

Posted

Can anyone get a black notification bar working on Vanilla 1.7 please?

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.