Skip to content

Instantly share code, notes, and snippets.

@onyxmueller
Last active March 17, 2017 03:36
Show Gist options
  • Save onyxmueller/cd95ba74b7591eebe30347891f02ef65 to your computer and use it in GitHub Desktop.
Save onyxmueller/cd95ba74b7591eebe30347891f02ef65 to your computer and use it in GitHub Desktop.
Add ZopFli Compression To Android Release APKs
// 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')
}
}
}
}
}
@penkzhou
Copy link

So if I want to add this progress to my CI server, I should install zipalign on my CI server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment