Zipalign implemented in java with 0 dependencies.
Note: I haven't implemented Zip64 handling yet, this might not work on a few apks.
Either you build a jar, import the gradle module, or just copy the classes.
To build a jar, run:
$ ./gradlew jar
and you'll have the built jar in the build/libs
directory.
You can use the jar as a library and directly access the ZipAlign
class.
import com.iyxan23.zipalignjava.ZipAlign;
FileInputStream zipIn = ...;
FileOutputStream zipOut = ...;
ZipAlign.alignZip(zipIn, zipOut);
// hell yeah it's that easy!
NOTE: The library doesn't do anything to verify if the zip stream given is valid; it assumes everything is valid and skims through bytes. You might need to verify the zip file first.
or just run it as a cli program:
$ ls
unaligned.apk zipalign-java-1.0.jar
$ java -jar zipalign-java-1.0.jar unaligned.apk aligned.apk
Aligning zip
Zip successfully aligned
$ ls
aligned.apk unaligned.apk zipalign-java-1.0.jar