Since an APK file is just a Zip file with a different extension and a few meta parameters, it seems that there is a way to change the compression level of the file.
Just to verify that Eclipse isn't exporting with the highest compression level, I've tried to pack the contents of the APK on my own with the compression level set to via winrar, and I got a reduction of 20% which
about 1 MB.
I couldn't find any easy way to repack the APK safely without deleting the metadata. I've tried with 7zip , aapt, apktool.
You can use the following ant task to repack apk:
<target name="-post-package">
<exec executable="${z7zip}">
<arg value="x"/>
<arg value="-o${out.dir}/TempApk"/>
<arg value="${out.packaged.file}"/>
</exec>
<delete file="${out.packaged.file}" verbose="${verbose}"/>
<exec executable="${z7zip}" dir="${out.dir}/TempApk">
<arg value="a"/>
<arg value="-tzip"/>
<arg value="-mx9"/>
<arg value="-r"/>
<arg value="${out.packaged.file}"/>
<arg value="*.*"/>
</exec>
<delete dir="${out.dir}/TempApk" verbose="${verbose}" />
It uses 7zip. Path to 7zip should be in the local.properties:
z7zip=C:\\Program Files\\7-Zip\\7z.exe
It gives about 15% better compression. Of course you can use any other tool or just execute these command lines manually to repack your apk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With