Our very good friend XJ has done a lot of work to remove the mystery from apktool and to automate the batch processing, decompiling, recompiling and flashable zip creation, etc when translating miui apks and building language packs
The following explanation is written by XJ and assumes some familarity with apktool. If you are not familiar with apktool it may be best to read the our tutorial on apktool first
REQUIREMENTS:
This for Windows computers ONLY it was tested on Windows 7 64 bit and should work fine on Windows XP and Windows 7 32 bit
You must have java installed on your machine, you may even have it already, mine is this per the main log file java version “1.6.0_21″
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
You can download XJ’s tools from here
USAGE
Download the zip pack from the bottom of the first post on XJ’s XDA Site, extract it into a folder and run AutoAPKToolMain.bat
QUICK HOW TO
THE 1-2-3-4 + 18 PROCESS
Place ALL apks to decompile in _INPUT_APK folder
- Place the framework-res apk in the _INPUT_APK as well (filename: framework-res.apk)
Choose 1 then hit enter for if framework-res.apk command
(note that framework-res.apk will always be in the _INPUT_APK folder)
Choose 2 to decompile all in one shot
(this will create the resources and sources folder inside _INPUT_APK folder)
- Do your edits for all in that folder, add your values-en, values-pt, raw-en, etc.
You may add drawable-en-hdpi as well
Edit your strings.xml and many more…
Remember to keep the folder structure intact
After all edits are done
Choose 3 and hit enter
This will recompile all in one shot
A notepad will appear to show if there are errors in recompiling, check the log
Adjust if necessary, you can choose to recompile a single folder if you need to
Choose 4 to build usable APKs
All apks will be in the _OUT_APK folder (These will not FC)
All overwriting of files are automated
These APKs are from the Original apk with:
resource.arsc + classes.dex changed + other resources added
Choose 18 (the fun part, lol)
It will build your flashable zip signed already, there’s a template in the _FLASHABLES folder
You may edit it, replace it with the same name, just keep templates by renaming, place your build.prop there, etc
Read the text file thoroughly…
So that is the short story….
For other options and features read the ReadMeHistory.txt
FYI, read notes below (in _OUT_APKTOOL_DIST folder, those are build by APK Tool)
I manage to build APKs that don’t FC in the _OUT_APKTOOL_DIST only that…… (see txt for complete explanation)
EXAMPLE 1: IMAGE
If you are overwriting an image in an APK (widget_1x.png)
_CUSTOM_RES
-MiuiMusic
–res
—drawable-hdpi
—-widget_1x.png (this is the image i will overwrite)
Otherwise if you are adding folders no need to turn on “overwrite resources), put all your files in:
_INPUT_APK
-MiuiMusic
–res
—drawable-de-hdpi (this is the image folder i added)
—-widget_1x.png
The Copy added resources “ON” will take care of copying these added resources or files
SOME EXAMPLES OF IMAGES AND FILES OVERRIDING:
“_CUSTOM_RES\AppShare\res\drawable-hdpi\installed.png”
“_CUSTOM_RES\Gallery\res\menu\media_context_menu.x ml”
“_CUSTOM_RES\ThemeManager\res\drawable-hdpi\desktop_mask.png”
EXAMPLE 2: XML BINARY WHEN YOU DO DIRECT EDITS
Say you are editing a file straight from framework-res\res\drawable\progress_horizontal.xml
FOR NOW YOU HAVE TO DO THIS:
1) After doing [3], recompiling the apk
2) Copy the file _INPUT_APK\framework-res\build\apk\res\drawable\progress_horizontal.xml
to _CUSTOM_RES\framework-res\res\drawable\progress_horizontal.xml
(this is the binary of your edited file, by doing this, you are telling the tool to overwrite it when building the apk)
3) Once this is done, make sure that “Overwrite res using _CUSTOM_RES” is ON, it is ON by default
4) then do build usable, It should overwrite those binaries in the APK
NOTES:
“Build Usable APKs” perform these depending on options
- overwrite resources.arsc (ON/OFF)
- overwrite classes.dex (ON/OFF)
- copy added resources (e.g. drawable-de-hdpi) (ON/OFF)
- overwrite any file in APK using _CUSTOM_RES (ON/OFF)
- copy optimized pngs to APK (ON/OFF) – EXPERIMENTAL @ the moment (20110503)
CREDITS
Brut.all for Apktool – a tool for reengineering apk files
http://www.7-zip.org – 7za commandline version
signapk.jar
optipng http://code.google.com/p/roptipng/
and XJ of course
