If an empty file exists in an APK - it causes no-compression for files with the same extension after rebuilding the APK. And, as a result, APK size increases, sometimes significantly, compared to the original APK.
This issue is a special case of issue #1572, which can be solved much easier than the whole #1572. #1572 is currently blocked by #1272, that has no planned fix.
assets/ folder. Let's call these files empty.dat and big.dat. Don't try to avoid compression of the mentioned .dat files in the APK. Rather, try to add them compressed.unzip -v command.big.dat is added with DEFLATE compression method into the APK. For empty.dat the compression does not make sense, so it is added with STORE compression method into the APK.apktool d and apktool b commands. Check the produced apktool.yml files.dat extension is added to the doNotCompress list.unzip -v command.big.dat and empty.dat use STORE compression method in the rebuilt APK. The rebuilt APK size is significantly bigger than the original APK size.big.dat should still use DEFLATE method.Currently Apktool enforces non-compression for files with the same extension if at least one such file is stored non-compressed in the original APK. But, as mentioned above, "compression method" concept does not really make sense for zero-length files. Thus compression method should be ignored for zero-length files. Files should not be marked for non-compression just because there is an empty file with the same extension. The solution is thus to check that a file is not zero-length, before adding its extension to the doNotCompress list. Such solution should be easy to implement.
apktool d, apktool b without changing anything? - Yes.Uploading reproduce.zip, containing scripts for reproducing the issue.
Usage:
reproduce.zip into some directory.apktool-cli-all.jar into the same directory../reproduce.sh
Confirmed. Thanks for detailed solution.
I believe best course of action is what you described, a check for zero-length size and if so, skip adding that file/extension to the doNotCompress list.
Merged. Thank you!
Most helpful comment
Merged. Thank you!