Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot watch Kotlin variable in android studio

I am not able to get android studio display the value of a calculation in the watches window.

I use Kotlin for development and when i try to add a value to watches, i get a message which says "An exception occurs during evaluate expression".

e.g.

   val model = MyModel()
   val pos = model.position

Now if I add model.position to watches, then it gives the above error and the value of the expression is not displayed.

How can I fix this?

like image 509
vishnus Avatar asked Oct 16 '16 08:10

vishnus


People also ask

How do you use variables in Kotlin?

Kotlin uses two different keywords to declare variables: val and var . Use val for a variable whose value never changes. You can't reassign a value to a variable that was declared using val . Use var for a variable whose value can change.

Can you code Kotlin in Android Studio?

Android Studio provides full support for Kotlin, enabling you to add Kotlin files to your existing project and convert Java language code to Kotlin. You can then use all of Android Studio's existing tools with your Kotlin code, including autocomplete, lint checking, refactoring, debugging, and more.


1 Answers

That's bug in Android studio.

1) I've reported mentioned bug (or very similar) recently: https://issuetracker.google.com/issues/62859634

2) If you find a bug in tools, report it to Google: https://issuetracker.google.com/issues/new

like image 77
Pointer Null Avatar answered Oct 05 '22 10:10

Pointer Null