Monday, April 14, 2014

APKTool Basics: Modding Android Apps

I know there's so many of you who wants to try editing or creating their own taste by modifying android apps or APK files. Here is the guide which you can use as your start to modding.

Here are the process which you need to know about APKTool Basics: Modding Android Apps.

First we must setup everything required apps. Download them here.
Now extract APKTool to:
C:\APKTool\
After all mentioned above, we are now ready for modding.

I. Installing Framework
II. Decompiling
III. Start Editing
IV. Recompile
V. Signing


APKTool Basics: Modding Android Apps

I. INSTALLING FRAMEWORK

Installing your ROM's framework will be the first thing to do when modding to obtain compatibility.

1. You must take/copy the "framework-res.apk" file from your current ROM and place it to APKTool folder, you can find it at "system/framework/framework-res.apk".

2. Go to APKTool folder and run "Command Prompt" file as administrator.

3. A command prompt will appear and type this command.
apktool if framework-res.apk

II. DECOMPILING

Decompiling is the process of decoding or producing the source codes of any program. Without decompiling a program, it is impossible to be read by human. We must decompile APK files so we can be able to edit XML files and smali files. 

To decompile an APK file, you must place it to APKTool folder and run command prompt. So this is the command to decompile.
apktool d sample.apk sample_folder
In my case I want to decompile my SystemUI.apk which is responsible for Statusbar elements.


After successful decompiling APK, a folder will be created as what you named it.

III. EDITING

This is the difficult part of modding. For now, start with replacing icons and PNGs but be sure it has the same file extension and the same size. 
You can find the icons and PNGs used in the APK by opening the decompiled APK folder

\res\drawable-nodpi
\res\drawable-hdpi or mdpi or ldpi, depends on your screen resolution.

I'll be posting more of it soon so let's just stick with the basic guides.

IV. RECOMPILING

This will be the stage of rebuilding the codes, XMLs and smali files back into a single APK file. To recompile, simply run the command prompt follow this command:
apktool b sample_folder_name new_sample.apk
In my case, I want to recompile my decompiled SystemUI folder.


V. SIGNING APK

Sign only non system apps unless you have modified AndroidManifest.xml file. From command prompt, type:
java -jar SignApk.jar testkey.x509.pem testkey.pk8 sample.apk signed_sample.apk

Done!




Credits to Rizal Lovins for the signing keys.

No comments:

Post a Comment