[Thunderbolt Themes and Apps] tsachi:
Decompiling and recompiling files

Modifying files by decompile/recompile

What is APK manager?

APK manager is a tool for decompiling / recompiling apk files. If you want to change anything other than images, it is a must have. EDIT: A new thread for APK manager 5 is out, make sure you don't get the old 4.9 version.

The basics

The basic flow when using APK manager is

Place apk file in place-apk-here-for-modding folder

run the Script.bat file

Type 22 and select the file you want to work with

For AOSP based: Type 9 and wait for it to finish decompiling

For Sense based: Type 10. When prompted, drag your com.htc.resources.apk onto the script window, then hit enter

Modify the items you want modified (they will be in the projects folder)

type 11 to recompile

When prompted about system file answer YES

When prompted about copying files over answer NO

Item 6 is where all the magic happens. Go to the projects folder and you will find a sub-folder with the apk name. Inside you have res, where you can replace images and work on xml files.

Bad starting file

This is mostly true for framework files that went through several cycles of modifications. The framework is forgiving to having extra items, or having bad .9 images (see post above about .9 images). Some people may have replaced images without recompiling the framework in a way that breaks the .9 format. The program saves an empty file with the .9.png extensions and a copy of the original without .9 in it. If this happens you will very likely see warning messages during the decompile stage, but you don't see warnings unless you look at the log. This means that you would actually catch it only at recompile. See this post for more details and how to solve this.

Things may not always be "fixable", so the best approach is to get the original framework that is the base for the one you need. Having a clean start can save a lot of headaches later on.

Overwriting your changes

When you recompile, assuming everything worked ok, you are prompted if this is a system file. Most likely you want to say yes. This ensures that the original signature is copied over. You will also be prompted if you want to copy some files over from the original. BE CAREFUL!. There are people who say you reduce the risk of errors if you copy things that didn't change. Personally, if I changed anything that required recompilation (mostly added new images or modified xml files) I always choose not to copy extra files. If you do choose to copy some files over, pay attention to the next step. Do not hit any key until you remove the modified files. You will need to go to the newly created "keep" folder (in the top apk manager directory) and remove any image that you changed and any xml that you modified. Also, if you modified xml files to add new images you need to delete "resources.arsc".

Failed rebuild

APK manager is trying to minimize work by only compiling newly changed items. If you built an apk and realized you have an error, or want to add more changes, I recommend removing the cached build. Go to the projects folder and delete the "build" folder. I've had cases where the new items didn't catch.

Removed items

I highly recommend to leave icons that you do not need. I've had occasions where I removed things that I thought had no more reference, but then ended with endless boot-loops. For example, if you modify the xml to only show 6 out of the 101 battery charge animations, leave the remaining icons in your project.

If you're stuck

Look at the log file. That would usually give you an answer. Also, if you are working on a recent GB ROM you probably need to get the beta 5 version. Version 4.9 will have problems compiling the newer files.