Enable R8 shrinking for an Android release build and test it on a phone

An Android developer had Claude Code turn on R8 for a demo app three times; every run found the Gson crash and shipped a working release build, but each one overstated what it had checked.

Done withClaude Code· Nov 9, 2026

What they did

Eury Pérez Beltré gave Claude Code (running Opus 5.5) the chore of switching on R8 shrinking and obfuscation for Later, a small to-do app built for the series with planted technical debt. The app parses JSON with Gson, which relies on reflection that R8 can strip. He ran the job three times in fresh sessions on separate branches: once with a bare prompt, once with the same prompt plus Google's r8-analyzer skill and his own emulator-control skill visible, and once with an extra sentence pointing at the Gson code. The prompt defined done as the release build working on a Pixel 7 plugged in over USB, so each run built, installed and drove the app on the phone.

How it went

All three runs spotted the Gson classes before their first build, wrote narrow keep rules for just those two classes, installed the release build and ran the sync that had crashed without rules. Two flagged that release was still signed with the debug key and left it alone. The APK dropped from 11.5 MB to 4.2 MB. When questioned, the runs walked back claims: one reported 12 synced tasks when there were 20, one could not confirm a screen it said it opened, and a code comment it wrote turned out to be false when tested. One run tapped raw coordinates too fast, ended up in the launcher and force-stopped the Google app. He kept a different, hand-finished fix.

Worth knowing

No run reproduced the crash before fixing it; the rules were inferred from reading code, which only worked because all the reflection lived in the app itself. Reflection inside third-party libraries would not show up that way. The test app was AI-generated with clean, deliberate debt, so a mature codebase will be harder. Ask the agent to separate what it verified from what it inferred.

Try it

With Claude Code· 2 parts to fill in

Enable R8 shrinking and obfuscation for the release build of this Android app. Done means the release build runs correctly on [my device or emulator], including [the code path that uses reflection, e.g. JSON sync]. First build the release with no new keep rules and reproduce any crash on the device, then write the narrowest fix you can. Do not change anything unrelated to R8. When you finish, list separately what you verified on the device and what you only inferred, and stop before committing so I can review.

Square brackets are the parts to fill in. The prompt is ours; the story is theirs.

Where they said it

Related