Skip to content

ADFA-3604: Fix Gson model classes and JDI debugger connector stripped by R8 - #1615

Merged
davidschachterADFA merged 4 commits into
stagefrom
fix/ADFA-3604-gson-jdi-r8-shrink
Aug 2, 2026
Merged

ADFA-3604: Fix Gson model classes and JDI debugger connector stripped by R8#1615
davidschachterADFA merged 4 commits into
stagefrom
fix/ADFA-3604-gson-jdi-r8-shrink

Conversation

@davidschachterADFA

Copy link
Copy Markdown
Collaborator

Summary

Two more R8 shrink bugs in the ADFA-3604 series (Gson-via-reflection and JDI's ServiceLoader-based connectors -- same root cause as the earlier fixes already on stage: R8 can't trace reflective/ServiceLoader instantiation, so it strips no-arg constructors it thinks are unused).

  • Gson model classes (d8b7f3f1d): templates-impl's TemplatesIndex/TemplateJson/etc., plus two more found by auditing every gson.fromJson call site in the repo -- OpenedFilesCache/OpenedFile (had no prior keep rule at all) and the breakpoint persistence models.
  • JDI debugger connector (74e27524a): SocketAttachingConnector/SocketListeningConnector stripped, causing java.lang.Error: no Connectors loaded (surfaced on-device as a misleading "Network access error" dialog -- the debug-connect failure handler always appends that suggestion regardless of actual cause). The fix was already anticipated and left commented out in proguard-rules.pro from before shrinking was enabled; just needed uncommenting.
  • Comment fix (b4e28fe21): corrected a stale positional reference ("above" -> "below") in a proguard-rules.pro comment from the previous commit.

Test plan

  • Verified on-device: JDWP listener starts successfully, no dialog, zero FATAL EXCEPTION in logcat
  • Verified on-device: template loading and opened-files-cache persistence work without the "Abstract classes can't be instantiated" error
  • :app:assembleV8Release builds clean from this branch and installs/runs without ANRs

Generated with Claude Code

davidschachterADFAand others added 3 commits July 31, 2026 17:34
Found via a "Failed to load template archive ... Abstract classes can't
be instantiated!" error on-device. Same root cause as the other shrink
bugs fixed in this branch: Gson deserializes these classes only via
reflection (gson.fromJson(..., X::class.java)), never a direct `new`
R8 can trace, so it strips the constructor and Gson's runtime then
reports the class as abstract.
Fixes templates-impl's TemplatesIndex/TemplateJson/etc., and two more
instances found by auditing every gson.fromJson call site in the repo:
OpenedFilesCache/OpenedFile (no prior rule at all) and the breakpoint
persistence models.
Verified on-device: templates load cleanly, zero FATAL EXCEPTION in
logcat, Kotlin project init still succeeds.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Found via a "Network access error" dialog on-device -- misleading, since
the app's debug-connect failure handler always appends a network-access
suggestion regardless of actual cause. The real error was buried in
logcat: "java.lang.Error: no Connectors loaded" from
com.sun.tools.jdi.VirtualMachineManagerImpl, caused by a
ServiceConfigurationError failing to instantiate
SocketAttachingConnector/SocketListeningConnector. Same root cause as
the other shrink bugs: JDI loads these via ServiceLoader, which R8
can't trace, so it stripped their no-arg constructors.
This exact fix was already anticipated and left commented out in this
file ("Initial rules to enable when R8 is shrinking to address
exceptions") from before shrinking was ever genuinely enabled -- just
needed uncommenting now that it is.
Verified on-device: JDWP listener starts successfully, no dialog, zero
FATAL EXCEPTION in logcat.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The Gson keep-rule comment said the templates.impl.zip rule was
"above" when it's actually below in the file.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@claudeclaudeBot 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3206e050-2c28-4787-8132-571450a5a735

📥 Commits

Reviewing files that changed from the base of the PR and between 0fb615a and b4e28fe.

📒 Files selected for processing (1)
  • app/proguard-rules.pro

📝 Walkthrough
  • Added R8 keep rules for Gson-reflected AndroidIDE, LSP debug, and template ZIP model classes.
  • Enabled keep rules for JDI socket attaching and listening connectors loaded through ServiceLoader.
  • Corrected a stale positional reference in proguard-rules.pro.
  • Verified template loading, opened-files-cache persistence, and JDWP listener startup on-device.
  • Verified the :app:assembleV8Release build.
  • Risk: Package-wide keep rules can increase APK size and reduce shrinking and obfuscation effectiveness.

Walkthrough

The ProGuard configuration now uses package-wide keep rules for AndroidIDE and template ZIP models. It also enables retention rules for com.sun.tools.jdi and com.sun.jdi classes.

Changes

ProGuard keep rules

Layer / File(s)Summary
Model retention rules
app/proguard-rules.pro
Package-wide rules retain AndroidIDE models, LSP debug models, and Gson-deserialized template ZIP models.
JDI retention rules
app/proguard-rules.pro
Enabled rules retain com.sun.tools.jdi and com.sun.jdi classes, providers, and constructors during shrinking.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit checks the shrinking spell,
Models stay where Gson can tell.
JDI classes keep their place,
Providers load with steady grace.
Hop, hop—retention wins!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly identifies the R8 fixes for Gson model classes and the JDI debugger connector.
Description check✅ PassedThe description directly explains the Gson and JDI R8 fixes, the comment correction, and the verification results.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-3604-gson-jdi-r8-shrink

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@davidschachterADFA
davidschachterADFA merged commit eb699b1 into stageAug 2, 2026
4 checks passed
@davidschachterADFA
davidschachterADFA deleted the fix/ADFA-3604-gson-jdi-r8-shrink branch August 2, 2026 23:54
Sign up for freeto 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

@davidschachterADFA