MergeSmali for Users

The basic idea behind patching is to take an existing apk file application, convert it to Smali code, patch the Smali code using Mergesmali, then finally convert the Smali code back to an apk application. apktool is the program for converting to and from Smali code. mergesmali.exe is the program for patching the smali.

When an apk file is converted to Smali, a deep class tree is created. The Smali code for the class com.example.Heatsink would be in the file smali\com\example\Heatsink.smali. The patch for this class would also be called Heatsink.smali, but it need not be in any particular directory.

Here is an example of how to patch an application:

apktool d myapp.apk -o \Scratchdir mergesmali /v \Scratchdir\smali \Extracted\Heatsink.smali apktool b \Scratchdir -o mynewapp.apk jarsigner mynewapp.apk arguments_for_however_you_want_to_sign_this