[HOW TO] Use and install APKtool

So, here i'm again porting a tutorial based on DSM_'s Tut 

What do you need:
JRE (Java Runtime Environment)

Install:

Windows:
Download apktool 
Download apktool-install-windows
Unpack both pakages you will get three files, copy those files to your Windows directory i.e. C:\WINDOWS

Decoding files:
Open Command. Run>cmd
Type-
Quote
apktool d file.apk [directory]
Example - apktool d D:\nfsshift.apk D:\nfsshift
Done!


FrameworkFiles

Apktool needs the framework files to decode and build apks.

Standard framework is embedded into apktool, so you don't need to do anything for most apk files. But some manufacturers, for example Samsung, add their own framework files and use them in system apps. To use apktool against such apps, you must pull framework from a device and install/register it to apktool.

For Example, you want to decode TouchWizLauncher.apk from Android v2.2 of Galaxy 5. If you try to do that, you will get an error message:


You need to install framework in apktool Type-

apktool if [framework location]


I have the got the framework-res.apk & twframework-res.apk by extracting the ROM. You can also copy it from your phone. But take care you must copy framework.apk from that ROM in which you got the Application file.




Then try again 


Now is working.


How to build decoded files:
Just type

apktool b [directory in which you have decoded the files]
Example - apktool b D:\nfsshift
Done!



You will find the apk file inside the decoded directory, like I found it in - D:\nfsshift\dist\nfsshift.apk

Now you need to sign your APK file.


How to Sign APK files:


When publishing an application or a custom rom you need to sign the .apk or .zip files with a certificate using a private key. The Android system uses the certificate to identify the author of an application and establish trust relationship between applications. The classic way of doing this was to use keytool then sign it with jarsigner. In this tutorial i’ll explain an alternative method which is relatively easy to use for most people using a tool called SignApk.jar.

First download the SignAPK tool - http://www.mediafire.com/?rw57ftajd6nm81s
Extract them to a directory you will remember. I have put them in C:\SignApk

Now just open cmd and type -
Quote

cd C:\SignApk
java -jar signapk.jar certificate.pem key.pk8 your-app.apk your-app-signed.apk
Example - java -jar signapk.jar certificate.pem key.pk8 D:\nfsshift\dist\nfsshift.apk D:\nfsshift\dist\nfsshift-signed.apk



Your APK is signed and can be installed.