Mastering Android APK Size: Youku’s 5‑Year Package Slimming Journey
Over five years, Youku’s Android team systematically reduced APK size through specialized and continuous governance, employing remote modules, whole‑package optimizations, and precise analysis tools like Franky, ultimately cutting the app from over 120 MB to under 65 MB while maintaining performance and stability.
Five‑Year Governance Review
Since 2017 Youku has invested five years in Android APK size governance, moving from a chaotic growth phase to a sustainable, low‑cost maintenance model. The effort is divided into three special‑governance periods and two continuous‑governance periods.
1.1 Special Governance (2017‑2018)
Technical means: offline unused modules, remote‑bundle, image compression & vectorization.
Strategy: single‑point refactoring of major issues.
Organization: small, loosely‑coupled team.
1.2 Continuous Governance (2020‑present)
Focus on precise analysis, tooling, and distributed responsibility.
All client teams participate, shifting from a "center‑heavy" to a "PVP" collaborative model.
Key tools: franky plugin, CLI analyzer, and size‑gate platform.
Governance Modes
The two modes are Special‑type (short‑term, rapid shrink) and Normal‑type (long‑term, steady reduction). Special‑type achieves quick wins but often rebounds; Normal‑type integrates size control into daily development like stability and performance.
Technical Support
Accurate byte‑level size measurement is the foundation. It includes four steps: measurement, guidance, evaluation, and responsibility attribution . The core tool franky provides:
Element‑level real size in the APK.
Aggregation to modules, features, business, and teams.
Detection of nine slim‑item categories (unused classes, un‑obfuscated classes, oversized resources, duplicate resources, multi‑dimensional resources, transparent PNGs, similar resources, non‑standard STL usage, unused export symbols).
Slimming Techniques
Techniques are grouped into three categories:
Remote‑ization : move code, bundles, or resources to the server (remote‑so, remote‑bundle, remote‑resource).
Whole‑Package Slimming : Proguard/R8, D8, R‑class merging, Dex layout optimization, byte‑code instruction reduction, resource shrinking, image compression, resources.arsc compression, duplicate removal, resource obfuscation, debug‑symbol stripping, ABI splitting, 7z compression.
Single‑Point Slimming : address each slim‑item directly in source code (e.g., remove unused classes, delete oversized resources, clean up duplicate assets).
Future Directions
Continued exploration is needed for deeper SO analysis, smarter Proguard rule assistance, and better library design. Emerging AndroidX components and vendor SDKs will bring new challenges and opportunities for further size reduction.
Key Diagrams
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
