Last active
March 17, 2017 03:36
-
-
Save onyxmueller/cd95ba74b7591eebe30347891f02ef65 to your computer and use it in GitHub Desktop.
Add ZopFli Compression To Android Release APKs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apply ZopFli compression to an APK at the command-line | |
zipalign -z 4 infile.apk outfile.apk | |
// Add the following to your build.gradle | |
//add zopfli to variants with release build type | |
android.applicationVariants.all { variant -> | |
if (variant.buildType.name == 'release') { | |
variant.outputs.each { output -> | |
output.assemble.doLast { | |
println "Zopflifying... it might take a while" | |
exec { | |
commandLine output.zipAlign.zipAlignExe,'-f','-z', '4', output.outputFile.absolutePath , output.outputFile.absolutePath.replaceAll('\\.apk$', '-zopfli.apk') | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So if I want to add this progress to my CI server, I should install zipalign on my CI server?