perf: shrink classes.dex from ~932KB to ~47KB#26
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (2)
WalkthroughThe pull request strips the app module of its Material UI dependency stack. Four 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
Summary
Reduces
classes.dexby 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.appcompatand 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— removematerial,appcompat,core-ktx, andtracingdependencies (keptuiautomator).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 assembleDebugsucceeds.androidx.test.uiautomator(5), and a handful of Kotlin stdlib classes — no appcompat/material/etc.Test plan
DeviceKitServer,ViewTreeDump)ClipboardBroadcastReceiverstill receivesclipper.setPackageListerstill runs viaapp_processSummary by cubic
Shrinks
classes.dexby ~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, andandroidx.test.uiautomator.Refactors
@android:style/Theme.Material.Light.NoActionBar(API 21+, minSdk 29).values-night/themes.xmlsince day/night theming isn’t used.Dependencies
material,appcompat,core-ktx,tracing.androidx.uiautomator(still excludingjunit).Written for commit e4a70d8. Summary will update on new commits.