Shrinking Android

Some libraries in Android were put in without removing the parts of the code that are no longer being used. In order to shrink the build size to put in useful things instead of cruft, I am working on reducing the size of libraries.

Binary Reduction

Some libraries I'm setting my sights on:

  • external/dbus - Android only uses a small subset of dbus (280984 bytes)
  • external/libcrypto - Possibly unused stuff (762820 bytes)

  • external/sqlite - Could be cruft here (302984 bytes)
  • external/icu4c - Tricky to get the data small (icudata is 1.5MB)

Compressing Resources

Currently Android stores its resources in UTF-16 which is the native format for Java. However, this wastes a lot of space with languages that use Latin-1 characters (English, French, etc).

This seems like a textbook case in which SCSU would be a perfect match. It stores using 50% the space as UTF-16 for all Latin-1 languages and other languages that fit in an 8-bit span such as Hindi. Most other languages cluster closely around the 50% mark with Turkish being 48% and Vietnamese being 35% compression. Japanese trails the pack with 15% compression.

I submitted a patch to use UTF-8 resources to the Android review tool. It makes the generic-eng system.img smaller by approximately 1.5MB.

Copyright © Kenny Root. All rights reserved.