Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 2.1 debugger does not show local variables

I am trying to debug over network in Android Studio. I connected via port 5555 and generally it is possible step through break points. But it often takes minutes just to execute one line of code and the other thing is that I don't see any variables which are no members. All I see is the this object, but no variables from within methods. How can I enable it?

enter image description here

As you can see I am within the method and at least the activity object is initialized, but it is not visible in the variables monitor.

UPDATE:

The problem remains when using USB debugging. No local variables are visible, not even when trying to evaluate expressions while debugging:

enter image description here

Android Studio 2.1, Gradle 2.1.0, Java 1.8

like image 812
4ndro1d Avatar asked May 10 '16 15:05

4ndro1d


People also ask

How do I show variables in debug mode?

The most commonly used way to look at variables is the DataTip. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable.

What is USB debugging in Android Studio?

USB Debugging allows an Android device to communicate with a computer that's running the Android SDK in order to use advanced operations.

How do I enable debug on APK?

To start debugging an APK, click Profile or debug APK from the Android Studio Welcome screen. Or, if you already have a project open, click File > Profile or Debug APK from the menu bar. In the next dialog window, select the APK you want to import into Android Studio and click OK.


2 Answers

Had the same problem.

There is a bug in Android Studio, see https://code.google.com/p/android/issues/detail?id=93730

They recommend removing in build.gradle (app), this fixed the issue for me.

android {     buildTypes {         debug {             ...             testCoverageEnabled true         }     } } 
like image 126
vasquez Avatar answered Oct 10 '22 01:10

vasquez


After a while of figuring out this same issue, I realized I was running a release build rather than a debug build.

The build variants window may not be open in Android Studio by default. Go to Tool Windows -> Build Variants. In the Build Variants window, select the appropriate build.

In your app.gradle file, make sure debuggable is set to true in the build variant you would like to debug:

android {     // ...     buildTypes {        release {          // ...       }        debug {          debuggable true       }     }     // ...  } 

If you would like to debug your release build, go ahead and add debuggable true to your release build.

Hope this helps!

like image 39
Orlando G Rodriguez Avatar answered Oct 10 '22 01:10

Orlando G Rodriguez