Skip to content

Group DEX treemap by known libraries#641

Draft
trevor-e wants to merge 1 commit into
mainfrom
trevorelkins/eme-108-group-dex-by-known-libraries-119a
Draft

Group DEX treemap by known libraries#641
trevor-e wants to merge 1 commit into
mainfrom
trevorelkins/eme-108-group-dex-by-known-libraries-119a

Conversation

@trevor-e

@trevor-e trevor-e commented Jul 1, 2026

Copy link
Copy Markdown
Member

The Android DEX treemap groups classes purely by package hierarchy, so third-party SDKs are indistinguishable from the app's own code. This is the Android analog of #632 (group iOS by known libraries).

This adds a curated catalog of well-known Android libraries (android_known_libraries.py) keyed by distinctive package prefixes (AndroidX, Kotlin, Firebase, Sentry, OkHttp, etc.). In DexElementBuilder, recognized classes are pulled out and grouped under a single Libraries node — keyed by canonical library name, with the matched prefix stripped from the nested hierarchy — while first-party code keeps its normal package tree. Sizes are preserved (each class is placed exactly once), so no new TreemapType/frontend changes are needed.

The catalog is intentionally conservative and easy to extend. Prefixes are matched on package boundaries and the most specific prefix wins, so e.g. com.emergetools.snapshots groups as a library but a first-party com.emergetools.hackernews app does not.

Example (from the Hacker News test fixture):

Dex
├─ Libraries
│  ├─ AndroidX      ← 1.72 MB
│  ├─ Sentry        ← 474 KB
│  ├─ Kotlin        ← 350 KB
│  ├─ OkHttp / Okio / Retrofit …
├─ com              ← first-party, stays flat
├─ me
└─ org

Testing

  • New unit tests for resolve_known_library and for the grouping/prefix-stripping behavior.
  • Verified against the hn.apk fixture: DEX total size unchanged (3,122,393 bytes) with libraries correctly grouped.
  • make check passes (lint/format/types).

Recognized third-party libraries (AndroidX, Kotlin, Firebase, Sentry, etc.)
are pulled out of the DEX package hierarchy and grouped under a single
"Libraries" node, keyed by canonical library name with the matched package
prefix stripped. First-party code keeps its normal package tree. Sizes are
preserved since each class is placed exactly once.

Adds a conservative, easy-to-extend catalog of Android libraries keyed by
distinctive package prefixes. This is the Android analog of EME-139 (group
iOS by known libraries).

Generated with [Linear](https://linear.app/getsentry/issue/EME-108/group-dex-by-known-libraries#agent-session-d849543d)

Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
@linear-code

linear-code Bot commented Jul 1, 2026

Copy link
Copy Markdown

EME-108

@sentry

sentry Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
HackerNews com.emergetools.hackernews 3.8 (1) Release

Android

🔗 App Name App ID Version Configuration
Hacker News com.emergetools.hackernews 1.0.2 (13) Release

⚙️ launchpad-test-android Build Distribution Settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant