Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
sn0b0ard
Old
(Last edited by sn0b0ard; 31st July 2012 at 03:38 AM.)
#1  
sn0b0ard's Avatar
Senior Member - OP
Thanks Meter 116
Posts: 295
Join Date: Sep 2008
Prompt [DEPRECIATED] Apktool 1.4.4 [ v3.1 07/17/12 ] [ Decompile Sense 4.0 APKs / HTC APKs ]

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:

Code:
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://forum.xda-developers.com/show....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/How...he_Android_SDK

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

Installing Frameworks and Decompiling
Code:
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:

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

Then to install frameworks and decompile:
Code:
./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
Code:
patch -p0 -i framework-res_htc.patch

Now you should be able to recompile framework-res using apktool 1.4.4 without any errors:
Code:
./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:

Code:
./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:
Code:
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:
Code:
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://forum.xda-developers.com/show....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/
The Following 16 Users Say Thank You to sn0b0ard For This Useful Post: [ Click to Expand ]
 
reverepats
Old
#2  
reverepats's Avatar
Senior Member
Thanks Meter 2367
Posts: 4,495
Join Date: Dec 2010
Location: Boston,MA

 
DONATE TO ME
Quote:
Originally Posted by sn0b0ard View Post
Attachment back up! I recompiled apktool 1.4.4, compiled smali 1.3.4, and merged it into the apktool.jar file. I have been able to decompile / recompile SystemUI.apk and framework-res.apk without problems. I tried com.htc.resources.apk, and it decompiles without issue, but to recompile it needs XML edits that I don't have time to do at the moment.

I have compiled the newest apktool 1.4.4 (merged with smali 1.3.4) for Linux 64-bit (not tested on 32-bit).

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

Attached is the apktool.jar file, an apktool bash script and a patch file for use in fixing framework-res.apk XML files to compile with apktool.

Download Directions:
Download apktool-1.4.4_smali-1.3.4.tar.bz2
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).
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.
Now you need to patch some XML files in /res/values* -- just use the patch file I included.

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 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/.

Thank you to fernando sor for providing the original instructions and modded apktool 1.4.2 for decompiling Sense 4.0 framework.
http://forum.xda-developers.com/show....php?t=1601511
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/
Now i just gotta learn how to use this, and im in Business. Dieing to get into themeing a bit. THanks for this man.
Device: Sprint Samsung Galaxy S4
ROM:Crawrj's Deodexed Stock ROM
Kernel: Stock
Theme: My MODs
Follow Me


 
flex360
Old
(Last edited by flex360; 8th July 2012 at 02:05 PM.)
#3  
Account currently disabled
Thanks Meter 3673
Posts: 2,665
Join Date: Sep 2010
this is what ive been using

http://forum.xda-developers.com/show....php?t=1189971

apkchanger is much easier, no typing of commands or anything
and yes it decompiles sense 4 apks with ease
 
sn0b0ard
Old
#4  
sn0b0ard's Avatar
Senior Member - OP
Thanks Meter 116
Posts: 295
Join Date: Sep 2008
Quote:
Originally Posted by flex360 View Post
this is what ive been using

http://forum.xda-developers.com/show....php?t=1189971

apkchanger is much easier, no typing of commands or anything
and yes it decompiles sense 4 apks with ease
Yes, there are many scripts out there that automate using apktool. This is the latest version of apktool, which isn't included in most scripts yet. You could probably just use the apktool.jar file from this post and put it into apkchanger if you want. I'm also seeing that most modded apktools that decompile HTC APKs have a modified HeaderItem.java to get past errors when decompiling APKs. The version I posted has the entire Smali 1.3.4 build merged into apktool 1.4.4.
 
flex360
Old
#5  
Account currently disabled
Thanks Meter 3673
Posts: 2,665
Join Date: Sep 2010
thanks
 
Art2Fly
Old
#6  
Art2Fly's Avatar
Senior Member
Thanks Meter 348
Posts: 736
Join Date: Aug 2010
Can anyone try this to theme the status bar that has quick settings? I get force close

Sent from my EVO using xda app-developers app
 
ssojyeti2
Old
#7  
ssojyeti2's Avatar
Recognized Themer
Thanks Meter 1936
Posts: 2,573
Join Date: Jan 2011
Location: North Miami Beach

 
DONATE TO ME
Quote:
Originally Posted by Art2Fly View Post
Can anyone try this to theme the status bar that has quick settings? I get force close

Sent from my EVO using xda app-developers app
Try signing it.

Red.
 
sn0b0ard
Old
#8  
sn0b0ard's Avatar
Senior Member - OP
Thanks Meter 116
Posts: 295
Join Date: Sep 2008
Quote:
Originally Posted by reverepats View Post
Now i just gotta learn how to use this, and im in Business. Dieing to get into themeing a bit. THanks for this man.
No problem

This video should help you get started with apktool:
http://www.youtube.com/watch?v=017pMX8otf8
 
sn0b0ard
Old
#9  
sn0b0ard's Avatar
Senior Member - OP
Thanks Meter 116
Posts: 295
Join Date: Sep 2008
Quote:
Originally Posted by Art2Fly View Post
Can anyone try this to theme the status bar that has quick settings? I get force close

Sent from my EVO using xda app-developers app
In addition to signing the apk, as stated previously, you could also perform this mod and completely disable signature checking:

http://forum.xda-developers.com/show...63&postcount=1
The Following User Says Thank You to sn0b0ard For This Useful Post: [ Click to Expand ]
 
ssojyeti2
Old
#10  
ssojyeti2's Avatar
Recognized Themer
Thanks Meter 1936
Posts: 2,573
Join Date: Jan 2011
Location: North Miami Beach

 
DONATE TO ME
Quote:
Originally Posted by sn0b0ard View Post
In addition to signing the apk, as stated previously, you could also perform this mod and completely disable signature checking:

http://forum.xda-developers.com/show...63&postcount=1
I will definitely be trying this.

Red.

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...