Search code examples
androidandroid-studioapkandroid-install-apkpngcrush

APK file size not changed after running pngcrush on over 1000 images


I have generated a release APK file for a word game with game board and letter tile images and its size is 14.157.885 bytes.

Then I have run pngcrush on about 1000 images in my Android Studio project, then "Clean Project", "Rebuild Project" and finally "Generate Signed APK..." again.

Surprisingly the resulting APK file is bigger size: 14.158.735 bytes

explorer screenshot

I have same result with Android Studio on Windows 7 x64 and Mac OS Yosemite.

Below you can see how bitmap sizes were indeed reduced by pngcrush - in the git log:

git screenshot

Surely the APK file is some kind of ZIP-archive - but why has its size increased?

UPDATE:

The real reason for asking this question is because I include a gzipped SQLite file (size: 4.988.928 bytes) using SQLiteAssetHelper and am worried - if the APK file is small enough to run on older Android devices.


Solution

  • aapt has a pngcrush equivalent built in, and runs it on your input files as part of the resource packaging process. With highly-optimized input files, you may be robbing aapt of the opportunity to run its own optimizations.

    If you'd rather use your own, you can disable aapt's through a gradle setting:

    aaptOptions {
        cruncherEnabled = false
    }
    

    Source: Issue 65335: aapt can make PNG files larger if they have been already optimized