By simply setting a TextViews text to a string defined in code (that never can be null) I sometimes get a ArrayIndexOutOfBoundsException, this only happens in my live app, I never had this issue on any test device yet... And it seems to happen sometimes only, user tells me it happens once and the next time everything works again. Any ideas what could be the cause here? For me it looks like this crash should never ever happen...
Code
I do following:
fun updateFilterInfo(showing: Int, total: Int) {
binding?.tvFilterLvl1?.text = "$showing / $total" // <= THIS line creates the crash
}
Crash
And I get following crash every now and then (very rarely):
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:973)
at android.text.SpannableStringBuilder.getSpans(SpannableStringBuilder.java:866)
at android.text.SpannableStringBuilder.getSpans(SpannableStringBuilder.java:836)
at android.text.SpannableStringBuilder.sendSpanAdded(SpannableStringBuilder.java:1268)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:773)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:672)
at android.widget.TextView.setText(TextView.java:5981)
at android.widget.TextView.setText(TextView.java:5849)
at android.widget.TextView.setText(TextView.java:5806)
... above line of my code ...
Versions/Background
I'm using android x, newest stable versions and have this problem... Also I use kotlin 1.3.21 and gradle plugin 3.3.2 - all this are stable and mostly the newest versions. Additonally I made sure the user does not use a custom rom, so it can't be this either.
from Setting TextView text to static text crashes (rarely) with ArrayIndexOutOfBoundsException
No comments:
Post a Comment