Skip to content

fix(android): JNI-based setChecked to span AndroidX.Core 1.16/1.17 - #23262

Merged
MartinZikmund merged 1 commit into
masterfrom
dev/mazi/22999-jni
May 14, 2026
Merged

MartinZikmund merged 1 commit into
masterfrom
dev/mazi/22999-jni

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

Summary

Fixes #22999 by calling AccessibilityNodeInfoCompat.setChecked through JNI rather than the managed C# property.

Xamarin.AndroidX.Core 1.17.0 changed the setChecked binding from setChecked(boolean) to setChecked(int) (state constants). When Uno.UI is compiled against one binding version and the consuming app pulls in the other transitively (the reported case was Sentry.Bindings.Android ≥ 6.2.0 dragging in Core 1.17.0), the managed setter throws MissingMethodException at runtime.

Both binding versions wrap the same underlying Java method whose JNI signature simply changed from (Z)V to (I)V. The new AccessibilityNodeInfoCompatJni helper probes both signatures once on first use and dispatches to whichever the loaded binding exposes — no managed reflection, AOT/trim safe.

Alternative to #23097

This is a deliberately narrower path than the already-merged #23097, which solved the same crash by bumping Xamarin.AndroidX.AppCompat 1.7.0.7 → 1.7.1.3 and cascading newer Activity / Fragment / Lifecycle / SavedState / Collection bindings, plus raising SupportedOSPlatformVersion to 23. That cascade in turn forced uno.templates to either bump matching bindings on its side or ride the new minSdk 23 floor, and broke Microsoft.Maui.Controls 10.0.60's transitively-pinned older .Ktx packages (NU1605/NU1608).

The JNI helper here resolves #22999 without touching AppCompat, the surrounding AndroidX stack, the minimum Android API level, or Maui's binding pins. Branch is based on the commit immediately before #23097 merged, so the PR diff shows exactly the cost of the fix.

⚠️ The branch base is pre-#23097. Conflicts with current master are expected and need manual reconciliation if this approach is preferred over #23097.

Test plan

  • Build Uno.UI.Runtime.Skia.Android against an AndroidX.Core 1.16.x baseline (default in the branch's base commit) and confirm node.Checked callers compile and run.
  • In a SamplesApp Android head, add a transitive dependency that forces Xamarin.AndroidX.Core 1.17.0+ (e.g. Sentry.Bindings.Android 6.3.0).
  • Trigger an accessibility focus change on a ToggleButton / CheckBox so UnoExploreByTouchHelper.OnPopulateNodeForVirtualView runs.
  • Confirm no MissingMethodException is logged and TalkBack reports the checked state correctly under both Core 1.16.x and 1.17.x.
  • Repeat against a NativeAOT build to confirm the JNI path is trim/AOT-safe (no IL2026/IL3050 warnings, no runtime null at the cached method id).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 13, 2026 12:15
@github-actions github-actions Bot added platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform area/skia ✏️ Categorizes an issue or PR as relevant to Skia labels May 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Android accessibility runtime compatibility issues by avoiding the managed AccessibilityNodeInfoCompat.Checked setter (which can throw MissingMethodException when the app restores a different AndroidX.Core binding version) and instead invoking setChecked via JNI while probing both (Z)V and (I)V signatures.

Changes:

  • Replaced the managed node.Checked = ... assignment with a JNI-based helper call in UnoExploreByTouchHelper.
  • Added AccessibilityNodeInfoCompatJni to probe and cache the available setChecked method signature at runtime and dispatch accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Uno.UI.Runtime.Skia.Android/Accessibility/UnoExploreByTouchHelper.cs Switches checked-state assignment to the new JNI helper to avoid binding mismatches at runtime.
src/Uno.UI.Runtime.Skia.Android/Accessibility/AccessibilityNodeInfoCompatJni.cs Introduces a JNI helper that probes setChecked signatures and calls the available one.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions Bot added area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation kind/documentation area/sdk Categorizes an issue or PR as relevant to the Uno.Sdk labels May 13, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@agneszitte
agneszitte force-pushed the dev/mazi/22999-jni branch from ced9c85 to e933487 Compare May 13, 2026 17:21
@github-actions github-actions Bot removed area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation kind/documentation area/sdk Categorizes an issue or PR as relevant to the Uno.Sdk labels May 13, 2026
AndroidX.Core 1.17.0 changed the AccessibilityNodeInfoCompat.setChecked
binding from setChecked(boolean) to setChecked(int) with state constants.
When Uno.UI is compiled against one binding version and the consuming
app pulls in the other (e.g. transitively via Sentry), the managed
setter throws MissingMethodException at runtime (fixes #22999).

This calls setChecked through JNI directly, probing both Java signatures
once and dispatching to whichever the loaded binding exposes. The C#
Checked property is no longer touched, so the fix stays neutral to the
AndroidX.Core version the final app ships - no AndroidX or
SupportedOSPlatformVersion bumps required.

Alternative path to #23097, which solved the same crash by bumping
AppCompat to 1.7.1.3 and cascading the AndroidX stack to minSdk 23.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund enabled auto-merge May 13, 2026 21:02
@MartinZikmund
MartinZikmund merged commit 43d2980 into master May 14, 2026
45 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/22999-jni branch May 14, 2026 01:07
@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/6.5

@mergify

mergify Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.5

✅ Backports have been created

Details

@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/6.6

@mergify

mergify Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.6

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request May 18, 2026
…6.6/pr-23262

fix(android): JNI-based setChecked to span AndroidX.Core 1.16/1.17 (backport #23262)
agneszitte added a commit that referenced this pull request May 18, 2026
…6.5/pr-23262

fix(android): JNI-based setChecked to span AndroidX.Core 1.16/1.17 (backport #23262)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MissingMethodException: AccessibilityNodeInfoCompat.set_Checked with AndroidX.Core 1.17.0

5 participants