Zucker: An Open‑Source Android APK Module Size Analysis Tool
Zucker is an open‑source Android utility that automatically analyzes APK module sizes by cloning projects, calculating unique AAR dependencies, simulating target AARs, and providing detailed reports to help developers reduce app bloat early in the development cycle.
Zucker, released as an open‑source project in March 2020, is a lightweight, non‑intrusive tool designed to dissect Android APK size composition by analyzing AAR modules and their unique dependencies.
Key Features
First tool to perform modular code‑structure analysis of APK size.
Runs in the developer's environment without modifying source code.
Script‑driven, highly flexible and extensible.
Automates size statistics, improving efficiency over manual methods.
Enables early detection of size‑related risks during requirement and integration phases.
Overall Architecture
The system consists of three main components: automated packaging statistics, dependency analysis, and target AAR simulation. It leverages Gradle’s caching, AIDL, and AAPT to compute the actual compressed size of AARs within the final APK.
Automated Packaging Statistics
The process clones the original project to avoid invasive changes, inserts a calculation script, and builds two cloned versions—one with the original AAR and one with the target AAR replaced. The size difference between the two builds yields the target AAR’s contribution.
Dependency Analysis
By executing ./gradlew dependencies , Zucker extracts the project's dependency tree, distinguishes between unique and public dependencies, and transforms the tree into a list structure that records parent‑child relationships for each AAR.
Unique Dependency Extraction
Collect all child dependencies of the target AAR.
Apply a depth‑first search to retain only those whose parents appear exclusively within the collected list.
The remaining nodes represent the target AAR’s unique dependencies.
Target AAR Simulation
The selected AAR is backed up, renamed to .zip , and extracted. All non‑resource files are zeroed out, then the archive is recompressed to simulate a minimal AAR, which is injected into the APK for size calculation. After packaging, the simulated AAR is removed and the original restored.
Future Plans
Display AAR size lists with graphical charts.
Link size data to specific feature requirements and generate correlation documentation.
Contribution & Feedback
Developers are encouraged to submit pull requests or issues via the GitHub repository https://github.com/wuba/Zucker and join the community for further discussion.
58 Tech
Official tech channel of 58, a platform for tech innovation, sharing, and communication.
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.