Repository navigation
fix(android): keep the by-name androidx members when the app minifies - #2
Merged
DD-Intercom merged 1 commit intoDec 4, 2026
Merged
Conversation
IntercomPlugin.initialize() installs the ViewTree lifecycle, saved-state and ViewModelStore owners on the Unity activity's decor view through reflection and Proxy dispatch on interface method names. When the app minifies with R8, the Class.forName strings are rewritten but the methods are renamed, so the setup throws and logs "Could not set view tree owners", and in-app messages built with Compose cannot render. The Android post-processor now appends exact keep rules for those members to unityLibrary's proguard-unity.txt, which the generated build already lists in consumerProguardFiles. The block also keeps IntercomPlugin's public static entry points and HeaderInterceptor.setUnityVersion, both reached only by name, so the wrapper no longer depends on the native SDK shipping keep rules for them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prithivraj
approved these changes
Dec 4, 2026
DD-Intercom
deleted the
dheepakraj.selvakumar/keep-viewtree-owner-reflection
branch
December 4, 2026 15:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
When a Unity app turns on minification, the Android bridge can no longer give the Unity activity a lifecycle. It looks up the androidx lifecycle and saved-state helpers by name, R8 renames them, so setup fails with "Could not set view tree owners" and in-app messages cannot render. Apps that don't minify are unaffected, which is why this has gone unnoticed.
How?
The Android build post-processor now adds exact keep rules for those androidx members to the file the generated library already passes to R8. The same rules keep the bridge's own by-name entry points, so the wrapper no longer relies on the native SDK to keep them.
Notes for reviewers
Checked with a minified build shaped like Unity's Gradle export: the bridge, a player stub and Android SDK 18.9.0 in a library module, launched from a plain
Activity, release build withproguard-android-optimizeand-repackageclasses '', on an API 36 emulator.Could not set view tree owners … Ld1.get [class android.view.View], and all three owners were null on the decor view.Not run inside the Unity editor, and no in-app message was rendered.
Generated with Claude Code