46

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?

enter image description here

Anthony
  • 3,989
  • 2
  • 30
  • 52
  • 2
    what 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 Answers6

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
  • 1
    i'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
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.

bendaf
  • 2,981
  • 5
  • 27
  • 62
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
1

Change'Build Variant' to debug

enter image description here

ImClarky
  • 1,933
  • 1
  • 25
  • 29
Diffey
  • 11
  • 4
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