Skip to content

Turn on R8 minify and resource shrinking for Android release builds - #117

Merged
KodeStar merged 3 commits into
mainfrom
fix/android-r8-minify
Oct 21, 2026
Merged

KodeStar merged 3 commits into
mainfrom
fix/android-r8-minify

Conversation

@KodeStar

Copy link
Copy Markdown
Owner

What / why

Play Console flags release 19 (2.0.0): "DEX code optimisation is below our threshold, Obfuscation (1%)", fix by Feb 2027. The generated android/app/build.gradle defaults android.enableMinifyInReleaseBuilds to false and app.json never set it, so release builds shipped unshrunk, unobfuscated bytecode.

  • app.json: expo-build-properties > android gains enableMinifyInReleaseBuilds and enableShrinkResourcesInReleaseBuilds.
  • plugins/build-properties.test.ts: asserts both.
  • CLAUDE.md: gotcha line (R8 is on; release-only ClassNotFound/NoSuchMethod gets a keep rule in extraProguardRules, never turn minify off; mapping ships in the AAB).

Android only. iOS has no equivalent requirement; the JS bundle is Hermes bytecode and unaffected.

Note: the Expo template uses proguard-android.txt (-dontoptimize), so R8 shrinks and renames but does not optimise. Play only flags the Obfuscation category, which renaming fixes; switching to the optimize profile is a possible follow-up.

Verification

Gate green (tsc, lint, format, jest 409 suites / 4949 tests).

Live on a Pixel 6a, release APK built from this branch (side-by-side app.audiosilo.dev):

  • R8 ran: minifyReleaseWithR8, 95.5% of classes renamed; APK 50.9 MB vs 63.8 MB unminified (about 20% smaller).
  • Launch, demo pairing, browse, play/seek/pause, media notification controls, download + offline playback, Cast chooser opens, kill + relaunch resumes position: all pass.
  • Logcat over the whole run: no FATAL, ClassNotFoundException, NoSuchMethodError, NoSuchFieldError or Resources$NotFoundException. No keep rules needed.
  • Not exercised: lock-screen controls, casting to a real receiver (no receiver discovered on the test network with minify on or off).

Pairs with KodeStar/audiosilo-docs (fix/android-r8-minify).

Play Console flags the release for DEX code optimisation/obfuscation
below its threshold. expo-build-properties now sets
enableMinifyInReleaseBuilds and enableShrinkResourcesInReleaseBuilds;
keep rules go in android.extraProguardRules.
@KodeStar
KodeStar merged commit 7a865fe into main Oct 21, 2026
1 check passed
@KodeStar
KodeStar deleted the fix/android-r8-minify branch October 21, 2026 08:55
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