Maximum compression level for .apk

Hello!
Maximum compression level for .apk in the repository, please start using.
This way, you can save a lot of space on the server hdd and reduce mobile internet traffic.

  • very much, unload in the end, the communication channels of your server.
1 Like

Isn’t that like level 6 ZIP always?

The best deflate compression is done by Zopfli - Wikipedia afaik.

1 Like

Well, surely there are more, even better.

But Android APKs are a certain format, .ZIP, so it must conform to it.

original size: 10646430

#using the libdeflate compressor. This is the default level of compression

advzip -z F-Droid-recent.apk
10646430 7811282 73% F-Droid-recent.apk
10646430 7811282 73%

# -4, --shrink-insane
# Set the compression level to “insane” using the zopfli compressor. You can define the compressor iterations with the -i, --iter option.

advzip -z4 F-Droid-recent.apk
7811282 7802174 99% F-Droid-recent.apk
7811282 7802174 99%

I think the default preset used is probably the middle preset zip, right?

Are there problems with reproducible builds if F-Droid starts to compress stronger? Do RB depend on the same hash sum?

It will break reproducible build. And I thoguht the compression needs to be done manually. See https://github.com/simplex-chat/simplex-chat/blob/v4.6.0/scripts/android/build-android.sh#L97-L100 for example.

build-android.sh#L97-L100 gets beyond my scope. Do you mean that zipalign sorts the beginning of files in the zip archive to 4 and that creates problems?

man zipalign:

-z Recompress using Zopfli

Couldn’t -z be used by all authors in the line from zipalign?

Couldn’t there an extra “advzip -z4 &&” after

&& zip -rq5 “$tmp/simplex-chat-armv7.apk” . &&

The file format isn’t changed by using zopfli.

I posted actual numbers here, it’d be way better to just zstd the app: Compressing APKs for storage/download - #12 by SkewedZeppelin

Are you sure, that the size of crocgui.zstd is right? I get at least 41MB with zstd -19

102M	com.github.howeyc.crocgui_28.apk
50M	com.github.howeyc.crocgui_28.apk.gz
23M	com.github.howeyc.crocgui_28.apk.zst

48M crocgui_28.apk.gz # zopfli (-i15 =default)
41M crocgui_28.apk.zst # zstd -19

@Jens a lot can change in 10 months

you should stick to the default levels with zstd, or not go past 7 as it becomes very slow to compress