Android OS Forum banner

[UTILITY]Zip Align in Windows

6813 Views 4 Replies 4 Participants Last post by  TommyB231
I don't know how many other people work in Windows frequently, but I do, and I wanted to zip align files in a ROM before packaging it for release. I couldn't find an easy method to do this posted anywhere else, so I created one. Here is a batch file that you can place in a folder, and it will go through the directory and sub-directories and zip align all apk files that are found. It's fairly simple, and I haven't seen any issues with it in my limited testing, but anything could happen, so you may want to keep a backup just in case. I posted it on Github, but will post the code here as well for anyone that may want it. Just copy and paste the below into a file with the extension of *.bat. Also, zipalign will need to be in your Windows $PATH for this to work properly. Hopefully, if you're using this, you can figure out how to do that, if not, you should before you use it.
@echo off<br />
REM Batch file to recursively zip align *.apk files in a directory<br />
REM and its sub-directories. This is significantly easier and faster<br />
REM than manually zip aligning them.<br />
@echo Zip aligning now...<br />
for /R %%X in (*.apk) do zipalign 4 "%%X" ""<br />
@echo Replacing non-aligned files with zip aligned files...<br />
for /R %%X in (*.new) do move /Y "%%X" "%%~dpX%%~nX.apk"<br />
@echo Zip aligning done, press any key to exit<br />
  • Like
Reactions: 4
1 - 5 of 5 Posts
Nifty. Thanks for this.
DrMacinyasha said:
Nifty. Thanks for this.
No problem. Not that zip aligning does to much, but I feel if it were simple, people may actually use it more often. I may try to make one for Linux/Unix then as well, since there are likely significantly more people doing work in Linux compared to Windows.
  • Like
Reactions: 1
Just wanted to say thanks, I was using APK multitool and it was failing on zipalign even with SDK installed...I tried this and it was failing as well even with zip align copied to windows and i copied it to the folder i was calling the bat from and it worked great...FWIW I am on windows 7 SP1 x64 with UAC turned off.
Thanks OP! This is more important than you think. In HTC Sense 4 and ICS, if you modify even uncompressed, compiled resources using 7zip on WorldClock.apk and don't zipalign, it force closes!
1 - 5 of 5 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.