'this@ActivityName' is not captured error Android/Kotlin

Viewed 10339

I'm repairing my friend's code and got confused.
My friend wants to fetch entered text (in EditText). Seems easy, right? Well, it is but instead of user input, he gets this warning/error:
enter image description here

To be honest I'm not sure how to fix it. He is coding in Kotlin (Android 10).
Activity that contains EditText: enter image description here

And XML:
enter image description here

This is how it looks when debugging:
enter image description here

The app started working just fine after running "File -> invalidate Cashes/Restart" option, I just don't understand where this warning came from and how to fix it because the error remained unchanged (even though the app works). Do you have an idea how to solve it?

All the best!

2 Answers

fyi lambda expression like setOnClickListener from kotlin is not debuggable, see here.

if you want to debug variables inside setOnClickListener you should use the normal one e.g. setOnClickListener(object: View.OnClickListener {..})

sometimes there will be problem in auto generated binding files, if so it will be solved after invalidate cache and restart ide. sometimes the warning/error show but the project and complied without errors. so no need to worry about that. for next time post the code as code not screen shots.

Related