How can I convert an apk file into an ultra-zip apk without affecting the executability of the android app?



  • I found out that when I zip the apk with ultra level zip compressor, the file size was effectively reduced. Why didnot developer let that compressed version out like js.minify? How to convert those apk file to ultra zip apk file?



  • APK files are usually only compressed using the compression setting "fast" (fastest (de)compression, only small space gained by compression). As far as I know this is for historical reasons.

    The first Android device were pretty slow and app installation time was already talking a lot of time. Therefore I assume Google decided to build all the Android developer tools in a way that the compression is focused of maximum speed and not on APK minimum size. As Google does not really have to care about size of cloud storage or bandwidth of network traffic this was the best solution.

    For that reason most Android build tools still only use the fast compression.

    Modern APK files e.g. generated by Google use a higher compression so the gain should be not that high anymore. But this depends on the app and who you got the APK file.

    Furthermore there are certain APK options which enforce that all the native libraries (.so files) have to stay unencrypted, if the app declares android:extractNativeLibs="false. Effectively this will save space in the end as the native libraries are not extracted from the APK file, instead they are directly used within the APK file, which means you only need to save it once on your device instead of two times (one time compressed in the APK, one time extracted).

    There are articles that describe how to recompress an APK file. Please be aware that these articles are very old and do no longer work with recent APK fiels and devices. This is because of the APK https://source.android.com/security/apksigning/v2 and v3 that do not only sign the decompressed content of the APK file (as v1 did) but instead they sign the APK file as a whole. So any modification to the APK file even if it does not affect the content (like adding a ZIP comment) will destroy the contained APK v2/v3 signature. As the v1 signature contains the info that there is a v2 signature all devices capable of checking a v2 signature will also reject such a modified APK file.

    Conclusion: On some APK file you could save some additional space by recompressing them but in nearly all cases it will today destroy the APK signature so it is not really an option.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2