Breakpoints not working on Android Studio 3.3
Asked Answered
S

4

21

After upgrading Android Studio to version 3.3 this week, some breakpoints are not being recognized as valid, and are not stopping the thread.

Am I missing anything?

enter image description here

Scholarship answered 22/1, 2019 at 15:36 Comment(15)
Have been on 3.3 for a while, no issues here. Make sure you debugger is attached to the instance and you've done a project resync/clean/rebuild.Meri
I had to upgrade gradle as well to clear up other unrelated issuesMeri
Thanks! Everything is up to date (3.3 and gradle 4.10.1), but still facing the breakpoint issue. :/Scholarship
those breakpoints are in your code or some SDK code or 3rd parties libs?Cannelloni
In my code. One is at an "init" method of a Fragment. The other one is inside a Retrofit request callback.Scholarship
and what about other breakpoints in the same class? tried to add in the first line of your Activity.onCreate where you call super.onCreate? is it fired?Cannelloni
Yes, I just added one right above the one that's not firing in my "init". It gets fired. When I hit F9, the next (original) one is ignored. This one doesn't have the checkmark when I'm running in debug mode. The above one has it.Scholarship
hmmmm, are you sure the code goes thru those lines? tried adding Log.d? if so, i would simply rm -rf build folder and try againCannelloni
Pretty sure. There's a condition on the second breakpoint. The code inside it is executed. I'll try to clean up the build folder. That's something I haven't tried yet.Scholarship
@Cannelloni Have found it. Not exactly what you said, but the breakpoint is not being hit. It's on a "if" statement line. Which used to work does not work anymore. It worked when I added the breakpoint inside the conditional statement. :/ Would you mind to write this answer @pskink?Scholarship
I will add to the weirdness. I am having this behavior only with "if`" inside of lambdas/anonymous. If statement breakpoints work fine within their own classes... Ideas?Halt
Try to add your breakpoint inside the "if" statement. It did work for me.Scholarship
What I noticed is that the if statements that have complicated logic in them do not work. So an "if (object.getSomething() == something)" will not work, but if you assign that to a value and then use the value in the statement it works fine... mystery deepens.Halt
I filled a bug report to Google. Here you can track it: issuetracker.google.com/issues/123651520Hatchett
Does this answer your question? android debugger does not stop at breakpointsLobster
D
4

The issue is in the build tool chain (gradle, d8/r8). Problem is fixed in Android Studio 3.4 Beta 1 with gradle 3.4.0-beta01.


Or a workaround solution for this issue can be used by locally updating the top-level build.gradle configuration for your project:

buildscript {
    repositories {
        maven {
            url 'http://storage.googleapis.com/r8-releases/raw' // ADD THIS.
        }
    }

    dependencies {
        classpath 'com.android.tools:r8:1.3.55'  // ADD THIS. Must be before the Gradle Plugin for Android.
        classpath 'com.android.tools.build:gradle:3.3'
    } 
}

Once the next point release of Android Gradle Plugins takes place these changes can be removed.


For more information, see: https://issuetracker.google.com/issues/122450679

Dressing answered 5/3, 2019 at 10:41 Comment(3)
Fixed on Android Studio 3.3.2Scholarship
@rafanasil I still suffer from this bug after upgrade to AS 3.3.2 last night. The same error happen with AS 3.5 canary 6 too. Which Gradle build tool version that you are using?Dressing
I'm using 3.3.2. After upgrading Android Studio and Gradle build tool I've got my breakpoints working fine.Scholarship
S
7

Found the answer with the help of @pskink. "If" statements are "invalid" locales for breakpoints. See the checkmarks below:

enter image description here

Scholarship answered 22/1, 2019 at 16:16 Comment(4)
What do you mean by invalid? Also I commented on the question about the behavior I am getting.Halt
"Invalid" means the Debugger won't reach that breakpoint. See the checkmarks on the breakpoints above during the execution. They're valid ones.Scholarship
I see. Then again your answer does not answer why this works this way now. if's were "valid" before. Now they aren't under circumstances (my comment under the question). Why is that happening?Halt
I am afraid that the "answer" is somewhat helpful, but does not provide a solution. I second @MadDim, why is that happening, it was working on AS 3.2. This is total bullshit. Probably is caused by some code optimization in the new AS/compiler/JVM...Hatchett
D
4

The issue is in the build tool chain (gradle, d8/r8). Problem is fixed in Android Studio 3.4 Beta 1 with gradle 3.4.0-beta01.


Or a workaround solution for this issue can be used by locally updating the top-level build.gradle configuration for your project:

buildscript {
    repositories {
        maven {
            url 'http://storage.googleapis.com/r8-releases/raw' // ADD THIS.
        }
    }

    dependencies {
        classpath 'com.android.tools:r8:1.3.55'  // ADD THIS. Must be before the Gradle Plugin for Android.
        classpath 'com.android.tools.build:gradle:3.3'
    } 
}

Once the next point release of Android Gradle Plugins takes place these changes can be removed.


For more information, see: https://issuetracker.google.com/issues/122450679

Dressing answered 5/3, 2019 at 10:41 Comment(3)
Fixed on Android Studio 3.3.2Scholarship
@rafanasil I still suffer from this bug after upgrade to AS 3.3.2 last night. The same error happen with AS 3.5 canary 6 too. Which Gradle build tool version that you are using?Dressing
I'm using 3.3.2. After upgrading Android Studio and Gradle build tool I've got my breakpoints working fine.Scholarship
C
0

I got the same problem. The problem is solved by upgrading Android Studio from 3.6.2 to 4.0.0

Carlitacarlo answered 20/8, 2020 at 22:42 Comment(0)
C
0

it works for android 4.0.1. there is a button "attach debugger to android process" on top menu bar. click it and select the process. then the debugger will hit the break point.

Carlitacarlo answered 21/8, 2020 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.