Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 956 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'this@ActivityName' is not captured error Android/Kotlin

#1
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][1]][1]

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][2]][2]

And XML:
[![enter image description here][3]][3]

This is how it looks when debugging:
[![enter image description here][4]][4]

**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!


[1]:

[2]:

[3]:

[4]:
Reply

#2
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.
Reply

#3
fyi lambda expression like setOnClickListener from kotlin is not debuggable, see [here][1].

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


[1]:

[To see links please register here]

Reply

#4
I understand that the question is regarding evaluating expression, but there is a way you can read variables from your debugger console, even if you're inside an anonymous callback. I found it helpful sometimes. Here are the steps:

- First enter debugger mode inside of your anonymous callback,
- In your debugger console, look at the right side for **"Frames"**
- Within **Frames** under [![main][1]][1], you'll see stack of function execution first top one on the list is the latest: [![enter image description here][2]][2]
- Click on row(s) below the latest function, until you find an instance of your activity **AddInformationActivity**. You will see the activity instance on the right side window under **Variables**. Don't go as far as selecting functions browned out, because those are from internal libraries.
- When you see you AddInformationActivity instance, you can expand it and see its variables.

Hope that helps!


[1]:

[2]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through