Skip to content

perf: shrink classes.dex from ~932KB to ~47KB#26

Merged
gmegidish merged 1 commit into
mainfrom
reduce-dex-size
Jun 16, 2026
Merged

perf: shrink classes.dex from ~932KB to ~47KB#26
gmegidish merged 1 commit into
mainfrom
reduce-dex-size

Conversation

@gmegidish

@gmegidish gmegidish commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Reduces classes.dex by 95% — from 953,956 bytes (~932KB) to 47,700 bytes (~47KB) — by dropping unused UI library dependencies and the Material theme that pulled them in.

Why so big?

The app's own code is only ~1,160 lines, yet the dex was ~932KB. The bloat came almost entirely from com.google.android.material + androidx.appcompat and their transitive deps (recyclerview, constraintlayout, transition, fragment, emoji2, lifecycle…).

None of these are referenced anywhere in the source — the only third-party class actually used is androidx.test.uiautomator.UiDevice. They were pulled in solely by the app theme (Theme.MaterialComponents.DayNight.DarkActionBar). Since this is a headless app (instrumentation entry points + a broadcast receiver, no <activity>), the theme is nominal.

Changes

  • app/build.gradle.kts — remove material, appcompat, core-ktx, and tracing dependencies (kept uiautomator).
  • app/src/main/res/values/themes.xml — swap the Material parent for the framework @android:style/Theme.Material.Light.NoActionBar (zero dex cost; available since API 21, minSdk is 29).
  • app/src/main/res/values-night/themes.xml — deleted (only existed for the Material day/night theme; no UI to theme).

Verification

  • ./gradlew assembleDebug succeeds.
  • Post-build dex contains only: project classes (21), androidx.test.uiautomator (5), and a handful of Kotlin stdlib classes — no appcompat/material/etc.

Test plan

  • Confirm instrumentation entry points still launch (DeviceKitServer, ViewTreeDump)
  • Confirm ClipboardBroadcastReceiver still receives clipper.set
  • Confirm PackageLister still runs via app_process

Summary by cubic

Shrinks classes.dex by ~95% (953,956 → 47,700 bytes) by removing unused UI libraries and switching to a zero-cost framework theme. The app is headless, so Material/AppCompat were only pulled in by the theme; build now includes project code, Kotlin stdlib, and androidx.test.uiautomator.

  • Refactors

    • Replace Theme.MaterialComponents.DayNight.DarkActionBar with @android:style/Theme.Material.Light.NoActionBar (API 21+, minSdk 29).
    • Remove values-night/themes.xml since day/night theming isn’t used.
  • Dependencies

    • Removed: material, appcompat, core-ktx, tracing.
    • Kept: androidx.uiautomator (still excluding junit).

Written for commit e4a70d8. Summary will update on new commits.

Review in cubic

Drop the unused UI library dependencies (material, appcompat, core-ktx,
tracing) and replace the Material app theme with a zero-cost framework
theme. None of these were referenced by the source — they were pulled in
solely by the Material theme. This app is headless (instrumentation +
broadcast receiver, no activity), so a framework theme is sufficient.

classes.dex: 953,956 -> 47,700 bytes
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: af14bfb2-e926-48b0-879b-9f9510c93b70

📥 Commits

Reviewing files that changed from the base of the PR and between 1d46386 and e4a70d8.

📒 Files selected for processing (3)
  • app/build.gradle.kts
  • app/src/main/res/values-night/themes.xml
  • app/src/main/res/values/themes.xml
💤 Files with no reviewable changes (2)
  • app/src/main/res/values-night/themes.xml
  • app/build.gradle.kts

Walkthrough

The pull request strips the app module of its Material UI dependency stack. Four implementation dependencies — core-ktx, tracing, appcompat, and material — are removed from app/build.gradle.kts. Correspondingly, app/src/main/res/values/themes.xml is rewritten to a minimal style that inherits @android:style/Theme.Material.Light.NoActionBar with no item overrides and a comment marking the app as headless. The night-mode theme file at app/src/main/res/values-night/themes.xml is deleted entirely.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the primary change—reducing classes.dex size by 95% through dependency and theme removal.
Description check ✅ Passed The description thoroughly explains the problem, solution, and verification steps, directly relating to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch reduce-dex-size

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@gmegidish gmegidish merged commit 194b76a into main Jun 16, 2026
8 checks passed
@gmegidish gmegidish deleted the reduce-dex-size branch June 16, 2026 09:24
gmegidish added a commit that referenced this pull request Jun 16, 2026
The dependency cleanup from the dex-shrink change (#26) was undone when
later feature branches — created before #26 landed — were merged, restoring
the full dependency list (core-ktx, tracing, appcompat, material,
uiautomator) and inflating classes.dex back to ~950KB.

None of these are used: the app theme is a framework theme and UiDevice was
replaced by UiAutomationFactory. Strip them again.

classes.dex back to ~49KB; 0 material/appcompat/uiautomator classes.
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