Skip to content

Commit 0cd347d

Browse files
authored
Catch NoSuchFieldError when reading bold text setting on non-compliant vendor runtimes (flutter#190972)
Some vendor-modified runtimes report API 31+ but omit the Configuration.fontWeightAdjustment field. Catch NoSuchFieldError at the Api31Impl call boundary in AccessibilityBridge and fall back to false rather than crashing at startup. Fixes flutter#190690
1 parent 9e5378c commit 0cd347d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,13 @@ private void setBoldTextFlag() {
709709
if (rootAccessibilityView.getResources() == null) {
710710
return;
711711
}
712-
boolean shouldBold =
713-
Api31Impl.isBoldText(rootAccessibilityView.getResources().getConfiguration());
712+
boolean shouldBold = false;
713+
try {
714+
shouldBold = Api31Impl.isBoldText(rootAccessibilityView.getResources().getConfiguration());
715+
} catch (NoSuchFieldError exception) {
716+
// Some vendor-modified runtimes report API 31+ but omit this API-31 field.
717+
// Treat bold-text detection as unavailable rather than crashing at startup.
718+
}
714719

715720
updateAccessibilityFeature(AccessibilityFeature.BOLD_TEXT, shouldBold);
716721
}

0 commit comments

Comments
 (0)