最近,由于 Android 内部抛出 IndexOutOfBoundsException,我们的应用程序发生了很多崩溃。
该问题发生在具有静态布局的屏幕上,该布局由 API 级别 26 -> 31 上的 TextView、复选框和按钮以及所有制造商组成。
我们无法以任何方式重现它,但我们尝试通过设置android:importantForAccessibility="no"
TextViews 来“盲目地”修复它。
我很高兴听到任何想法可能是什么问题:)
Fatal Exception: java.lang.IndexOutOfBoundsException: setSpan (-1 ... -1) starts before 0
at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1318)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676)
at android.view.accessibility.AccessibilityNodeInfo.setText(AccessibilityNodeInfo.java:2474)
at android.widget.TextView.onInitializeAccessibilityNodeInfoInternal(TextView.java:10642)
at android.view.View.onInitializeAccessibilityNodeInfo(View.java:7345)
at android.view.View.createAccessibilityNodeInfoInternal(View.java:7304)
at android.view.View.createAccessibilityNodeInfo(View.java:7289)
at android.view.accessibility.AccessibilityRecord.setSource(AccessibilityRecord.java:146)
at android.view.accessibility.AccessibilityRecord.setSource(AccessibilityRecord.java:119)
at android.view.View.onInitializeAccessibilityEventInternal(View.java:7241)
at android.widget.TextView.onInitializeAccessibilityEventInternal(TextView.java:10623)
at android.view.View.onInitializeAccessibilityEvent(View.java:7229)
at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:7091)
at android.view.View.sendAccessibilityEventUnchecked(View.java:7076)
at android.view.View$SendViewStateChangedAccessibilityEvent.run(View.java:26260)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)