Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find local variable while debugging

I'm trying to debug my application with the option Java Field Watchpoints. My variable is found first time it appears in my code (its initialisation) but right after that I've got this error:

Cannot find local variable 'variableName'

and I can't follow its modifications then.

I've been searching around and modified my gradle file as this:

   buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
       }
       debug {
           minifyEnabled false
           debuggable true
           testCoverageEnabled = true
       }
   }

My active build variant is debug (not release) so the error is not coming from here. I am using Android Studio 3.6 Canary 11

Does anyone encounter the same problem?

like image 237
Lena Avatar asked Sep 18 '19 09:09

Lena


People also ask

How to see value while debugging in Visual Studio?

Run and Debug view# To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D.

How to see Local variables in Visual Studio?

To open the Locals window, while debugging, select Debug > Windows > Locals, or press Alt+4. This topic applies to Visual Studio on Windows.

How to view variables in Visual Studio?

Right-click the variable in the data tip, and select Add Watch. The variable appears in the Watch window. If your Visual Studio edition supports more than one Watch window, the variable appears in Watch 1.

What is the difference between the Locals and Autos Windows?

The Locals will show local variables of the current scope. It usually starts with this , which represents the current class. The Autos window will show all variables used in the current line and in the previous line.


1 Answers

It could be a optimization by some part of the tool chain, like removing dead code, escape analysis, or indeed a bug in the runtime, see for some of the possibilities: https://www.guardsquare.com/en/blog/proguard-and-r8

Maybe unit testing your code and annotating it with debug logging will prove to be more successful.

like image 129
JohannesB Avatar answered Oct 24 '22 00:10

JohannesB