Android app crash in play store prelaunch report but working in real device

前端 未结 3 1662
执念已碎
执念已碎 2021-02-05 15:04

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

3条回答
  •  别那么骄傲
    2021-02-05 15:45

    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.

提交回复
热议问题