APK Package Size Optimization and Monitoring Platform for Android Apps
The platform optimizes Android APK size by shrinking resources, compressing images, filtering native libraries, and applying selective byte‑code reductions, then continuously monitors package composition, trends, and business‑line usage, alerting teams to abnormal growth while preserving functionality for large‑scale apps.
Package size reduction (shrink) is less urgent than crash handling, but for large‑scale apps such as DeWu with millions of daily active users it brings significant benefits.
Key benefits of shrinking the APK include higher download conversion, lower acquisition cost, faster installation, and improved runtime performance.
APK Composition
An unpacked APK mainly consists of libs (.so files), assets, res and code (dex). These components account for about 99% of the package size, so optimization focuses on them.
Resource Optimization
Resources (res, assets, resources.arsc, manifest) are the largest contributors. AAPT2 compiles resources into intermediate .flat files and generates R.java . Optimization steps include:
Reducing the number of resources in res .
Compressing images (PNG, GIF, JPEG) and converting to WebP.
Removing unused resources (shrinkResources).
Merging duplicate resources.
Assets are not processed by AAPT2; they are compressed or trimmed via the shrink plugin or custom scripts.
Library (.so) Optimization
Only the required ABI is kept via abiFilters . Dynamic delivery removes many .so files, but about 20 MB of native libraries remain in the APK and need careful handling.
DEX Optimization
DEX files occupy roughly half of the package. ProGuard is used only for obfuscation; shrinking and optimization are disabled due to third‑party library constraints. Selective byte‑code transformations (ByteX, Redex) are applied to inline constants, accessors, R classes, and delete unused methods.
Package Size Monitoring Platform
The platform parses APKs (using a customized ApkChecker), tracks size trends, breaks down resources by type and business line, and provides alerts when abnormal growth is detected.
Features include:
Trend monitoring of overall package size.
Business‑line‑level resource breakdown.
Resource traceability to AAR modules.
Dependency graph visualization.
APK comparison across builds.
Alert service integrated with Feishu bots.
Future work will strengthen code‑size monitoring, especially for DEX and native libraries, and continue to explore safe, high‑impact shrinkage techniques.
DeWu Technology
A platform for sharing and discussing tech knowledge, guiding you toward the cloud of technology.
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.