31

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

reducing activity
  • 1,985
  • 2
  • 36
  • 64
4ndro1d
  • 2,926
  • 7
  • 35
  • 65
  • So when you click on the `+` to the left of `this` is it not showing the variables within `this`? – AgileNinja May 10 '16 at 15:28
  • 1
    There are variables, but e.g. `activity` is a function variable which should definitely not be declared within this, but below as far as I remember – 4ndro1d May 10 '16 at 16:23
  • You are right! Just tried it and `activity` is listed below `this` and not within. I'm stumped. – AgileNinja May 10 '16 at 16:46
  • I just figured out that the problem remains when switching back to USB as well... T_T – 4ndro1d May 11 '16 at 12:34
  • is this problem because of the new Jackson compiler? I just started experiencing this very annoying issue, and it's slowing down my development considerably. – Gubatron Jul 30 '16 at 21:12

9 Answers9

19

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
        }
    }
}
vasquez
  • 449
  • 6
  • 8
15

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!

5

I tried setting testCoverageEnabled to false but that did not work for me. In my case, I had ProGuard enabled for my debug flavor and disabling it (i.e. setting minifiyEnabled to false) was the only thing that allowed me to be able to see my local variables while debugging again.

Marline
  • 269
  • 3
  • 10
3

In my case, it was because I had forgotten that my build variant was set to release. Toggling the variant back to debug and re-running correctly showed the local variables.

jcady
  • 3,850
  • 2
  • 21
  • 21
1

For me I had to set testCoverageEnabled to false like so:

android {
    buildTypes {
        debug {
            ...
            testCoverageEnabled false
        }
    }
}

When I had this set to true, I was not getting local variables

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156
0

While this is not a permanent solution to this problem, my most consistent fix (after trying the other answers here to no avail) has simply been restarting my computer.

lase
  • 2,508
  • 2
  • 24
  • 35
0

I tried some kind of hit n trial and made it work with the settings as seen in the attachment. FYI, using latest version of Android Studio 3.3.1 and gradle version 4.6.

enter image description here

enter image description here

SimplyProgrammer
  • 1,799
  • 2
  • 17
  • 28
Digvesh
  • 9
  • 2
  • Welcome to SO. You should 1) embed those images 2) provide some textual answer if they become unavailable. – m02ph3u5 Feb 07 '19 at 16:02
-1

I had same trouble. I completely reinstalled my IDE and the trouble has been disappeared. I hope my approach will help you.

0wl
  • 836
  • 8
  • 19
-3

Java 1.8 does not support accessing variable values.

Update Gradle to version 2.2.0-beta3:

In your gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

In your project build.gradle file

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0-beta3'
}