Reputation: 2976
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?
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:
Android Studio 2.1, Gradle 2.1.0, Java 1.8
Upvotes: 31
Views: 21069
Reputation: 9
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.
Upvotes: 0
Reputation: 3968
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.
Upvotes: 2
Reputation: 517
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!
Upvotes: 15
Reputation: 269
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.
Upvotes: 5
Reputation: 23483
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
Upvotes: 1
Reputation: 2634
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.
Upvotes: -1
Reputation: 876
I had same trouble. I completely reinstalled my IDE and the trouble has been disappeared. I hope my approach will help you.
Upvotes: -1
Reputation: 449
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
}
}
}
Upvotes: 19
Reputation: 50
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'
}
Upvotes: -3