java.lang.IllegalArgumentException : Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull
The last parameter can be null
, as described by the docs:
KeyEvent
: If triggered by an enter key, this is the event; otherwise, this is null.
So what you have to do is make the Kotlin type nullable to account for this, otherwise the injected null
check will crash your application when it gets a call with a null
value as you've already seen it:
edtSearch?.setOnEditorActionListener(object : TextView.OnEditorActionListener {
override fun onEditorAction(v: TextView, actionId: Int, event: KeyEvent?): Boolean {
...
}
})
More explanation about platform types in this answer.
To solve this issue, make the event
parameter nullable, if you use TextView.OnEditorActionListener
. Add ?
at the end of the declaration:
override fun onEditorAction(v: TextView, actionId: Int, event: KeyEvent?)