How To De/recompile An App
Decompiling and recompiling an Android app for the first time can seem quite complicated and time-consuming, but it really isn't once you know what you're doing.
First you'll need to choose which WorkArea you want to use. There are eight WorkAreas in total, which means you can easily work on up to eight different rom's or devices without having to reset the tool everytime you want to change from one to the other.
Inside each WorkArea are five folders. The '_in
' folder is where files about to be decompiled go, the '_working
' folder contains the results of that decompiling and the '_out
' folder contains the recompiled files. There's also a "Frameworks
" folder, which will contain the framework files you've installed. You can pretty much ignore that last one most of the time.
(When you first use TMA
, you'll be in WorkArea 1 by default.)
To decompile an app, you'll first need to put the relevant APK in the "_in
" folder. You can either copy this into the folder yourself or you can 'pull' it from your Android device. If you want to pull the file, this next section is for you. If you don't, skip ahead to the one after that.
How To Pull A File
First select the "Pull File[s] From Device
This gives you the option of pulling some of the most commonly modified system apps, or any other file you wish.
Choose which file you want to pull and the tool will try to do that for you. If the pull fails, it could be that you don't have the adb drivers installed on your PC for your particular device, or the file doesn't exist, or any one of a number of things. Have a look in the "history.txt
" file that's automatically generated to see what's going on.
That's actually all we need to know about pulling - it's really not that complicated. Once you've pulled all the files you need, you can move on to decompiling them. But you might need to install your frameworks first..
How To Install Framework Files
If you want to modify a system app (like SystemUI.apk or framework.jar) you'll need to install the right framework files. These are files that contain resources that are shared amongst most of the system apps. Those resources need to be made accessible to apktool (the program that does the actual decompiling) or the app won't decompile fully and it won't work.
There are many framework files available. Stock Android only comes with one (so far) and it's called "framework-res.apk
". OEM's like to include their own, though, just to make life more interesting. Samsung used to have "twframework-res.apk
" in their rom's before replacing it with "samsung-framework-res.apk
". Framework files are found in "system/framework
" on your devices internal memory and should be an APK file with "res" in the filename. You need to make sure you install every framework file in your rom to ensure a system app decompiles, so make sure they all are put in the "_in
Select the "Install Framework File[s]
" option and choose whether you want to install all the framework files in your WorkArea or some individual ones. You can select up to five individual files to install in one go.
If the tool isn't able to install the files you'll be shown an error, otherwise you'll go back to the install menu. If you've installed all the framework files you need to, go back to the title menu because we're finally ready to do some decompiling!
How To Decompile A File
Select the "Decompile File[s]
" option and choose whether you want to decompile all the files in the "_in" folder or individual ones.
Once you've chosen your files, you'll be asked whether you want to decompile with "Standard
" or "Advanced
" settings. This is new to Version 16 of Tickle My Android
. Apktool has a lot of different options when it comes to decompiling and you can now choose which ones you want to use. The standard settings will just make the tool try to decompile the entire file, as it used to in previous versions. The advanced settings let you control the process a little better..
These are the main decompile options available for the latest version of apktool available at time of writing (2.4.0.). Full explanations of each are available on the apktool github here: https://ibotpeaches.github.io/Apktoo...tation/#decode
. To give you an idea though, you can use "Don't Decode DEX Files
" if you don't want to modify any smali files, which makes the decompile a lot
Choose your options and the tool will try to decompile your file for you. If it succeeds the decompiled files will be in the "_working
" folder, if not you'll get an error message. The full details of that error will be in the "history.txt" file.
Once your app is decompiled you will be free to modify it however you like. Change images, alter layouts, add functionality..whatever you want to do. When you're done, you'll need to recompile your app to be able to use it again.
How To Recompile A File
Select the "Recompile File[s]
" option and choose whether you want to recompile all the files in the "_working" folder or individual ones.
Once you've chosen your files, you'll again be asked if you want to recompile with standard or advanced settings.
You can find explanations of the first few options on the apktool github again: https://ibotpeaches.github.io/Apktoo...ation/#rebuild
. It is very
important to know what the options that you've selected but there are two that's worth paying extra attention to..
"Copy Original "AndroidManifest.xml" And "META-INF" Folder
" - Modified system apps need to be signed with the same 'key' as the original app, or they won't run. This option ensures that the original key is used on the new app. If you want to change the Manifest file, though, you'll need a different key which involves disabling signature verification. That's a bit more complicated than this tool allows for..
"Use "aapt2" [apktool_2.3.2+]
" - More recent apps can be constructed with a newer version of a tool called aapt. If you're trying to modify a file made with the newer version, you'll need to have this option actve for the recompile to work. There's no easy way to tell if this is needed or not so, if you get an error, try again with the option turned off.
(Different versions of apktool will have different options. Selecting an option that isn't available on the version of apktool you're using will cause an error.)
There are also options to sign and zipalign your recompiled apps. Signing uses a generic key and zipaligning can sometimes break V2 signature checks so, if you've no idea what that all means, it's best to leave these options alone until you know you need them.
has an option to put your recompiled apps into a ZIP file that you can flash in a custom recovery. I'll go into this in more detail in the next post but I always recommend replacing system apps this way. It's much safer than trying to replace them while the phone is running.
Choose your settings and sit back while the tool does its thing.
Once it's finished you'll get a message saying the file recompiled...or one saying it didn't. If it didn't, you can find the full error text in history.txt.
If your file recompiled, you'll find it in the "_out" folder. It's now ready to go back to your phone.
It's up to you how you do that but the route I always
recommend above all others is using a flashable ZIP file. Check out the next post if you want to know more!