Apktool is a tool 😉 for reverse engendering 3rd party, closed, binary Android *.apk files. It can decode resources to nearly original form and then also rebuild them. Rebuild them also when you provide some modifications.
I create two simple apps to try apktool and basically check how it’s work. In directory we have two apps. First: app-debug.apk and app-debug-unaligned.apk. In this case, not matter really what’s are these apps for.
To use apktool simply open terminal and go to this directory where are yours app’s(app). Type:
and press ENTER. If everything it’s ok output should be similar to this one below:
In our directory, a new folder was created with name of the app. It contains all folders and files that are contained in the *.apk file, for example:
res folder
smali folder
original
AndroidManifest.xml
apktool.yml
From now ok we can:
analyze code
create modes
After we perform some edits, we can build our app. For this purpose I create separate folder and copy there decompile folder with all my changes:
To build application, we can use:
We can get something like that:
But I can’t get any *.apk file. But also at that point I was wrong. Why ? Because default directory for output file is:
Top build and receive *.apk file in the same catalog use:
If everything it’s ok output should be similar to this one below:
Now we can so that our new *.apk file is in the same directory like rest of files:
But sometimes command described before really don’t work, and you can receive similar android Exception:
I found soloution for that:
-f replace previous decompiled apk’s code
-r ignore the decompiling of resources
This would prevent the resources from being decompiled, will copy the same resources when you recompile the apk.