Not able to track crash in the project, I got this error in play store pre-launch section, it showing on click of EditText
, it got the error. but not getting any cr
In my case EditText did not have a maxLength
set. However we are using some custom InputFilter
. Here how it looks like:
private val textFilter = object : InputFilter {
override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence? {
return when {
good -> null // just allow change as is
bad -> "" // ignore change totally[*].
else -> magic // return a calculated value
}
}
}
Problem[*] was ignoring the value totally by returning empty String which was causing crash on Marshmellow and below devices. Here is how I have solved this:
private val textFilter = object : InputFilter {
override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence? {
return when {
good -> null // just allow change as is
bad -> (dest.toString() + source.subSequence(start, end)).subSequence(dstart, dstart + (end - start)) // ignore change totally[*].
else -> magic // return a calculated value
}
}
}
Key Point is not to return anything smaller than the change (end-start)
(on M and below devices).
I still thank previous answers which helped me to identify the root cause.