Skip to content

[Android][Accessibility] Startup crash in AccessibilityBridge when reading Configuration.fontWeightAdjustment #184286

Description

@lukemmtt

Steps to reproduce

This is currently production evidence rather than a local public repro project.

The crash occurs during Android app startup in Flutter's embedding stack:

  • io.flutter.view.AccessibilityBridge.setBoldTextFlag
  • io.flutter.view.AccessibilityBridge.<init>
  • io.flutter.embedding.android.FlutterView.attachToFlutterEngine
  • io.flutter.embedding.android.FlutterActivity.onCreate

Expected results

Flutter should safely determine whether bold text accessibility is enabled, or gracefully treat the feature as unavailable on runtimes where the field access is unsafe.

Actual results

The app crashes at startup with:

java.lang.NoSuchFieldError - No field fontWeightAdjustment of type I in class Landroid/content/res/Configuration; or its superclasses

Production evidence

From Firebase Crashlytics for a Flutter app pinned to Flutter 3.41.x:

  • 95 fatal events in the last 90 days for the same issue
  • 100% OnePlus (OnePlus8Pro)
  • 100% Android (11)
  • sampled events from app versions 9.4.2, 9.4.4, 9.4.7, and 9.4.13 all show the same main-thread stack landing in AccessibilityBridge.setBoldTextFlag

Representative stack:

io.flutter.view.AccessibilityBridge.setBoldTextFlag
io.flutter.view.AccessibilityBridge.<init>
io.flutter.embedding.android.FlutterView.attachToFlutterEngine
io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onCreateView
io.flutter.embedding.android.FlutterActivity.createFlutterView
io.flutter.embedding.android.FlutterActivity.onCreate

Why this looks like an embedding bug

The current engine code reads Configuration.fontWeightAdjustment directly inside AccessibilityBridge.setBoldTextFlag().

AndroidX Compose hardened this exact access pattern in July 2024:

That change moved the field access behind a dedicated API-31 helper rather than reading it directly in the main code path.

So this seems less like app code misuse and more like an embedding/runtime compatibility issue where the direct field reference is unsafe on at least some Android 11 / vendor runtimes.

Proposed direction

Mirror the AndroidX pattern in AccessibilityBridge:

  • move the fontWeightAdjustment access behind a @RequiresApi(31) helper
  • ideally mark the helper @DoNotInline
  • optionally treat NoSuchFieldError as "bold text unsupported" instead of crashing

Flutter doctor

Not attached because this is not from a local reproducible app sample yet.
I can provide a minimal patch against flutter/engine if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: crashStack traces logged to the consoleplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions