I get this message in debug windows in Android Studio. This is not a static method, nor is it a class. What does it mean?
Asked
Active
Viewed 2.8k times
46
-
2what happens if you step over once ? – Blackbelt Feb 01 '16 at 13:48
-
@IntelliJAmiya what do you mean by "use context" – Anthony Feb 15 '16 at 15:36
-
if I watch getContext(), it results in "this" is not available – Anthony Feb 15 '16 at 15:37
-
@Blackbelt if I step over, it continue as it should. (not done in thje screenshot, as my code changed, but in many case in this class CameraPreview) – Anthony Feb 15 '16 at 15:40
-
Maybe the code is not running on the main thread and that's why when you try to watch something related to context/main thread you get the message "'this' is not available"? – Sherekan Mar 02 '16 at 14:11
-
`this` might be not available when you're pointing to static fields, that was my first thought – agilob Mar 02 '16 at 14:23
-
@Sherekan do you mean that debugging outside of main thread make this unavailable from debugger point of view ? – Anthony Mar 03 '16 at 14:34
-
@Anthony Maybe the debugger can only show what is on the thread where the code is running. I'm not sure, just trying to provide another point of view. – Sherekan Mar 03 '16 at 15:00
-
strange thing here that it already knows the answer yellow text said it is equals zero. but debug console still does not know result. i noticed this behaviour some times console takes some time before show answer. is it your case or does it not show answer at all? – Konstantin Volkov Mar 05 '16 at 18:58
6 Answers
21
Inside Lambda block we can't evaluate the value of variables. Changing from the lambda expression to normal expression solved my issue

MarGin
- 2,078
- 1
- 17
- 28
-
1i'm sorry, this is true when i check debugging between lambda vs normal one. but, should android studio is capable to debug lambda? or is it impossible for google/intelliJ team to develop it from the first place? because i concern when changing lambda to the normal one, the android studio shows warning and suggest to use lambda instead, but it's weird if the lambda itself is not debuggable... – nashihu Aug 25 '21 at 08:56
-
This might help a bit : https://www.youtube.com/watch?v=CRzLZH68rRo - Debugging lambda in java. In this video the IDE is intelli-j only – pravingaikwad07 Jun 03 '23 at 20:59
15
I think this is an issue related to Reflexion. My project was using Hugo. As soon as I disable it, the bug disappeared.
Issue has been pushed : https://github.com/JakeWharton/hugo/issues/127

Anthony
- 3,989
- 2
- 30
- 52
-
Thanks , I was using Hugo and as soon as Hugo was disabled , the problem was solved – Raymond Chenon May 13 '16 at 14:11
-
4Here I am not using any Hugo but still getting the same issue, any solution? – Shailendra Madda Apr 24 '18 at 11:06
-
-
1In my case it happens when the variable is in lambda blocks, I replace with inner anonymous class and it returns normal. – Phong Nguyen May 23 '19 at 02:49
11
this
keyword is references to the current object instance, as in the the official Java documentation.
In your case the error message 'this' is not available
means that the debugger cannot access (i.e. does not know) the current object.

Antti Haapala -- Слава Україні
- 129,958
- 22
- 279
- 321

bendaf
- 2,981
- 5
- 27
- 62
-
-
2I think it's because the class is compiled without debug info for size and performance reasons. – bendaf Mar 03 '16 at 15:40
-
-
I assume it was in debug mode, otherwise I would not be able to debug at all. – Anthony Mar 03 '16 at 16:43
-
1Sure you can, just you don't see the variables that are optimized out ;) – bendaf Mar 03 '16 at 20:09
-
-
I tried to reproduce it, but weren't able to yet, is this your own class, or a built in Android one? Or maybe from some library? – bendaf Mar 05 '16 at 12:58
-
-
Check your build variants if all of them says "debug" than maybe the compat library compiles in release mode from some reason, I am not able to Google it now, but I will be back home tomorrow and check if there is a way to compile it in debug mode :/ – bendaf Mar 06 '16 at 07:46
-
-
@Anthony yes Antony. Is it because of it that I get the `"this" is not available" ? – Lisa Anne Mar 07 '16 at 17:38
-
@LisaAnne I pushed an issue. Did you solve somehow ? or just remove Hugo ? – Anthony Mar 07 '16 at 17:47
3
when i change my gradle config,the work for me. this is error config:
buildTypes {
release {
minifyEnabled true
zipAlignEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
minifyEnabled true
zipAlignEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
and, this is work for me.
debug {
minifyEnabled false
zipAlignEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}

didikee
- 449
- 5
- 9
-
This should be accepted as a right answer, worked for me, now my watch and debug variabes started to re-evaluate again while im debbuging! THX @didikee – Arthur Melo Sep 16 '20 at 22:29
-
0
I had to change the previous debug
code with this one:
buildTypes {
debug {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

Mattia Ferigutti
- 2,608
- 1
- 18
- 22