Sep 232012

In this post, you can find my pack/unpack notes for Android APKs(of course for educational purposes only ;)).

To accomplish this, you basically need JDK, Android-SDK(no surprise!) and apktool.

First we need to decode our application to “smali” code with apktool.

I usually decode only code part of application with “-r” option if I don’t want to edit resources. (Resource decoding and building can sometimes be error-prone! )

Now we have the smali code under “.\sample\smali\” directory and can edit it easily. If you are familiar with java bytecode, it will be no hard to understand and edit this code. (much more reasonable it is!)

Here is a smali assembly of simple HelloWorld class.

You can always refer to Dalvik Opcodes table from here.

After we edited our code we can now reconstruct our application apk with apktool.

In order to install this apk to our phone or emulator, it needs to be signed properly. To do this we should generate a key for signing:

It will ask for some information that can be entered freely.

Now we can sign our apk by using generated keystore.

Android needs apks to be aligned with 4-byte boundaries to be able to memory-map them.

Finally if all operations were executed successfully, we can install our edited application for testing. (in my case, to emulator!)

That is it! You can enjoy your non-restricted, ad-free and maybe new-featured application ;)

  • Cagdas

    Uygulama adi vermemissin bu sefer :P fizy dava acar diye mi korktun hehehe