skip to content

With Android Studio's APK Analyzer, how do you find out what made your app's download size grow after a release?

level: seniorimportance: nice to knowfreq 25%

answer

  1. diff against what users have
  2. raw size versus download size
  3. DEX counts per package
  4. mapping files from the same build

basics

~20 s

Open the new APK or app bundle in the APK Analyzer, use Compare with previous APK to diff it against the build last published, and read Download Size, the estimated compressed size Google Play delivers, to find which entities grew.

solid answer

~40 s

I open the candidate build with **Build > Analyze APK** (or drag it into the editor), then click **Compare with previous APK...** and pick the artifact last published to users. The comparison shows per-entity size differences, so the growth narrows to `classes*.dex`, `res/`, `lib/` or `assets/`. I read **Download Size**, the estimated compressed size as Google Play delivers it, rather than only **Raw File Size**, because the two can differ. If DEX grew, the DEX viewer's **Defined Methods** and **Referenced Methods** show which packages arrived. Loading `mapping.txt`, `usage.txt` and `seeds.txt` from the same build deobfuscates names, shows what R8 removed and bolds what keep rules retained, which can expose an over-broad keep rule. If resources grew, I preview the final entities and `resources.arsc`. The `apkanalyzer` command line does the same job in CI.

go deeper

for a junior

Recall how to open a build in the APK Analyzer and that it shows each file's size inside the APK or app bundle.

for a middle

Explain Raw File Size against Download Size, and Defined against Referenced Methods in the DEX viewer.

for a senior

Run the diff against the last published artifact, follow the growth into DEX or resources, and use the same build's mapping files to separate kept code from removed code.

for a principal

Decide whether a team gates releases on size, keeping published artifacts and mapping files and running apkanalyzer in CI, and what growth budget triggers a review.

## What the APK Analyzer reads The **APK Analyzer** is the Android Studio tool that opens a built **APK** or **Android App Bundle** after the build finishes and shows what is inside it. An APK is a ZIP file, and the analyzer shows each file and folder as an entity you can expand, mirroring the archive's structure. There are three ways in: - drag the APK or bundle into the editor window; - in the **Project** view, double-click the APK in `build/output/apks/`; - choose **Build > Analyze APK** and select the file. The same analysis is available from the command line as **`apkanalyzer`**, which is how a CI job can watch size. ## The size columns | Column | Meaning | |---|---| | **Raw File Size** | the entity's contribution to the total APK size, zipped | | **Download Size** | the **estimated compressed size** of the entity as Google Play would deliver it | | **% of Total Download Size** | the entity's share of the APK's total download size | The question is about what users download, so **Download Size** is the column to rank by. Raw size alone can mislead, because some files compress better than others in delivery. ## Diffing two builds The analyzer's comparison is built for exactly this situation: 1. Load the build you are about to publish into the APK Analyzer. 2. In the top-right corner, click **Compare with previous APK...**. 3. Select the artifact that was **last published to your users** and click OK. 4. Read the dialog, which lists size differences entity by entity, and follow the largest positive difference down. Compare like with like. A diff of a debug build against a release build shows the differences between build types, because they use different build options, mixed in with any real growth. ## When DEX grew The **DEX viewer** opens `classes.dex` and its siblings: - **Defined Methods** counts methods defined in that DEX file. - **Referenced Methods** counts every method the DEX references, including your code, libraries and framework methods. These count toward the **64K method limit** per DEX file. - **Italic nodes** are references without a definition in the selected DEX, such as framework methods. - Toggles show fields, methods and all referenced members. - **Load Proguard mappings...** takes `mapping.txt` (deobfuscates names), `usage.txt` (shows nodes R8 **removed**, in strikethrough) and `seeds.txt` (shows nodes the keep configuration **retains**, in bold). They must come from **the same build** that produced the DEX. - Right-click a node for **Show bytecode**, **Find usages** (who references it) and **Generate Proguard Keep rule**. A new package full of bold, kept nodes often points at a keep rule wider than intended. Writing and scoping keep rules is covered with the Android build tooling. The analyzer is how you see the effect. ## When resources or the manifest grew - Click an entity to preview its **final** version. Build steps change entities: shrinking alters code, and a product flavor can override an image resource. - The **`resources.arsc`** viewer shows configuration-specific values, such as every translation of a string resource, which is where a new language pack shows up. - The merged **`AndroidManifest.xml`** is shown as reconstructed XML, so a library's manifest contributions are visible. - `lib/` holds native libraries per ABI. A new dependency that ships native code shows up there, and in the comparison. ## Where growth usually hides The comparison tells you which folder grew. These are the usual suspects for each: | Entity | Typical cause of growth | What to open next | |---|---|---| | `classes*.dex` | a new library, or a keep rule that retains more code | the DEX viewer with the same build's mapping files | | `res/` | new or larger images, extra densities | entity previews of the final resources | | `resources.arsc` | new strings or translations | the `resources.arsc` viewer | | `lib/` | a dependency that ships native code | the per-ABI folders | | `assets/` | bundled files such as fonts or data | the entities themselves | Start with the largest **Download Size** difference. A large raw-size change that barely moves the download size matters less to users than its raw size suggests. ## Turning it into a routine 1. Keep the last published artifact, and its mapping files, for every release. 2. Compare before publishing, not after users notice. 3. Run `apkanalyzer` in CI so a large jump fails a check instead of reaching a store listing.

  • Why compare against the artifact last published instead of the debug build on your machine?
    Debug and release builds use different build options, so a debug-to-release diff mostly shows build-type differences rather than what changed between releases. Comparing the release candidate with the last published artifact isolates the growth users will actually download.
  • DEX grew by a library's worth of methods though nobody added a dependency directly; how do you trace it in the analyzer?
    Expand the DEX viewer by package to find the new one and its Referenced Methods count. Load `seeds.txt` from the same build to see whether keep rules retain it, and use Find usages to see what references it. Then fix the cause in the dependency graph or the keep rules.
  • Why must the mapping files come from the same build as the DEX you are viewing?
    Obfuscated names such as `a` or `b` are assigned per build, so a `mapping.txt` from another build maps them to the wrong classes and methods. `usage.txt` and `seeds.txt` describe that build's shrinking as well, so mismatched files mislabel what was removed or kept.

  • Raw File Size is the number users download from Google Play.
  • Any mapping.txt from the project deobfuscates any build's DEX.
  • Referenced Methods counts only the methods your own code defines.
  • The APK Analyzer opens APKs but not Android App Bundles.
  • Diffing the debug build against the release build shows what grew between releases.