[Sprint HTC EVO 4G LTE] sn0b0ard:
XDA user iBotPeaches now has a working Apktool 1.4.9. I recommend using this over the Apktool 1.4.4 I posted, as it is no longer necessary to modify XML files to recompile framework-res.apk and other APKs. I may post updated smali/baksmali binaries if anyone is interested, as I still build those frequently from the latest source.

[UTIL][July 28 2012] Apktool v1.4.9 - a tool for reverse engineering apk files

Apktool 1.4.4 with Smali 1.3.4

Version 3.1 is now posted!

Note: 3.1 is a maintenance release containing working aapt binaries. You only need to re-download it if you haven't installed the latest Android SDK Platform-tools rev. 12.

I have been able to decompile / recompile SystemUI.apk, framework-res.apk (with patch), Browser.apk, Swype.apk, com.htc.resources.apk (with patch) without problems.

Changelog:

07/17/12 - Version 3.1
Added aapt binaries from Android SDK Platform-tools rev. 12 (Both Linux and Windows)
Added README file
Removed patches from the archive (download attached patches / fixed XML as needed)

07/15/12 - Version 3
Compiled apktool 1.4.4 with newest smali 1.3.4-dev (as of 07/15/12)
Attached apktool 1.4.4 and smali 1.3.4-dev build script for Linux (use this to build apktool and smali from source)
Attached all fixed XML files for framework-res.apk (mainly for Windows users, Linux users can use patch)
Attached patch for com.htc.resources.apk
Attached all fixed XML files for com.htc.resources.apk (mainly for Windows users, Linux users can use patch)

07/09/12
Fixed the framework-res_htc.patch file.
Patch file is now posted for those who have already downloaded v2.
Updated archive to include fixed framework-res_htc.patch file.

07/08/12 - Version 2
Modified the build process for apktool so it doesn't compile with outdated brut.apktool.smali and builds exclusively with Smali 1.3.4.
Recompiled apktool 1.4.4
Added aapt binary for Linux
Added apktool.bat file for Windows users

07/07/12 - Initial version
Compiled apktool 1.4.4, compiled Smali 1.3.4, merged into apktool.jar.

Description:

I have compiled the newest apktool 1.4.4 (merged with smali 1.3.4).

In the attached archive are apktool.jar, aapt, and apktool scripts for Linux and Windows.

Also attached are XML patches for some HTC framework files so they will compile with apktool.

I wanted to be able to decompile framework-res.apk (Sense 4.0), and other HTC APKs, with the latest apktool.

Previously, the only way to properly get HTC apks and Sense 4.0 framework-res.apk to decompile was having to use an older apktool 1.4.2 (modded by fernando sor). Now that shouldn't be necessary :)

Notes:

This was compiled and tested on Linux 64-bit, although the .jar file should work with Linux 32-bit and Windows.

The patch files won't work on Windows because they use unified context (only GNU Patch for Linux supports unified context).

Windows users can use the fixed XML files I attached, or make the necessary XML edits yourself.

For instructions on patching framework-res.apk XML files from Windows, refer to this post:

http://xdaforums.com/showthread.php?t=1601511

Download Instructions

Download attachment apktool-1.4.4_v3.1.tar.bz2

Download attachments containing patches or fixed XML

Extract all files to a folder ~/apktools/apktool is what I personally use.

Make sure you have aapt in your path (check your ~/.bashrc file to make sure).

aapt Note: The aapt binary (Linux and Windows) is included in the attachment. You can use this aapt, or you can get aapt by installing android-sdk.

Refer to this excellent tutorial for detailed instructions on setting up android-sdk:

http://wiki.cyanogenmod.com/wiki/Howto:_Install_the_Android_SDK

​

chmod a+x aapt
chmod a+x apktool
chmod a+x apktool.jar

Installing Frameworks and Decompiling

cd ~/apktools/apktool

Copy over com.htc.resources.apk and framework-res.apk from /system/framework either by extracting a ROM .zip or using these adb commands:

adb pull /system/framework/com.htc.resources.apk
adb pull /system/framework/framework-res.apk

Then to install frameworks and decompile:

./apktool if com.htc.resources.apk
./apktool if framework-res.apk
./apktool d framework-res.apk

Ignore any warnings about integers being out of range.

Patching XML files and Recompiling

Linux users only: Use the patch files I attached. Instructions are below.

Windows or Linux users : Unzip patched XML file(s) into apktool folder and overwrite all files

​

patch -p0 -i framework-res_htc.patch

Now you should be able to recompile framework-res using apktool 1.4.4 without any errors:

./apktool b framework-res

Remember to extract the META-INF and AndroidManifest.xml from the ORIGINAL framework-res.apk to /framework-res/build/apk (signing apk) then build again:

./apktool b framework-res

Your signed framework-res.apk file will be in /framework-res/dist/.

Pushing Modified APK to Device

There are a few ways of doing this, but I will guide you through the process I use.

Connect your phone to your PC and issue the following command to boot into recovery:

adb reboot recovery

Once you are in recovery, make sure that /system is mounted.

Now issue these adb/shell commands to delete the existing APK and push the modified APK to your phone:

adb shell rm /system/framework/framework-res.apk
adb push framework-res.apk /system/framework
adb shell chmod 644 /system/framework/framework-res.apk

Now clear cache and dalvik cache in recovery and reboot system.

If your phone gets stuck in a boot loop or doesn't display the UI properly, then you didn't sign the APK properly.

Credits:

Thank you to fernando sor for providing the original instructions and modded apktool 1.4.2 for decompiling Sense 4.0 framework.

http://xdaforums.com/showthread.php?t=1601511

Thank you to ahecht for posting working aapt from Android SDK Platform-tools rev. 12

Thank you to brut.all for creating apktool :)

http://code.google.com/p/android-apktool/

Thank you to JesusFreke for creating smali :)

http://code.google.com/p/smali/