android debugger does not stop at breakpoints
Asked Answered
H

14

68

I am seeing debug statements in the console but the debugger does not stop on any breakpoints. I tried clearing all breakpoints and adding them back in. Not sure how this can happen but it is.

Hardee answered 14/3, 2011 at 0:5 Comment(1)
My solution was reinstalling Eclipse. Possible weaker solutions are: workspace cleaning (remove all eclipse file and import from the resulting project; Clean Project, Restart Eclipse.Monochromatism
P
19

Have you set the debuggable flag in the AndroidManifest? If you miss that, do so by adding android:debuggable="true" in the application tag. It should look like that in the end:

<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
Pentaprism answered 14/3, 2011 at 0:12 Comment(8)
And in the my case it won't help :-(Monochromatism
@Wooff you should post that as a separate answer. :)Doan
@Wooff as if I don't have enough files littering my dev folder. Are you saying I need another "debug" folder. I think Linux would be a more maintainable solution.Yate
Android Studio does not support this flag anymore.Hangdog
@ZdravkoDonev debuggable flag is now defined in build.gradle (see developer.android.com/studio/build/build-variants#build-types)Cassaba
@Monochromatism have you founded any solution?Threeply
@BhunnuBaba Yes, reinstalling Eclipse. Weaker solutions are: workspace cleaning (remove all eclipse file and import from the resulting project; Clean Project, Restart Eclipse.Monochromatism
I tried the solution but the android studio won't let me and shows me the message Avoid hardcoding the debug modeLafountain
C
79

Solution that worked for me:

  • Simply uninstall the app from the device (manually on the device) and try debugging again(!)
Capillarity answered 23/11, 2019 at 16:32 Comment(7)
You can't do easier than that =)Yashmak
Thanks! Worked fine!Hypnogenesis
That's rigth! On new phone I've tried Run and then Debug. After that breakpoints stopped work. After uninstall app from phone and rerun Debug mode, breakpoints started work againChristinachristine
I finally found the ultimate solution for my worst nightmare using Android Studio!Gamogenesis
I've been using Android Studio for years and have never had to do this. No idea what changed, but I just tried uninstalling it and it worked! Thanks!Bifocals
Try the solution from @Tibbetts - "Attach debugger to Android process", it may save you this trouble.Panteutonism
This works for me even for flutter as wellMaeda
C
59

If you use Android studio, click debug app instead of run app:

enter image description here

Cynthea answered 28/4, 2015 at 3:53 Comment(1)
Silly me! +1. This should be the accepted answer. Android studio warns you against putting android:debuggable="true" in the application manifest which is suggested in the accepted answer.Hadik
T
27

According to this answer, Inside build.gradle for your app module, disable minifyEnable for your build variant and change it to false. Then, it should be:

minifyEnabled false

othewise you will see Line number not available in class xxxx when you hover over breakpoint markers and they will be looked with a cross on them

Tiger answered 23/1, 2019 at 9:55 Comment(1)
I will add that I did not see the mentioned message when hovering the breakpoint. Non-working breakpoint were missing a little checkmark on it essentially leaving them as a plain red circle whereas the working breakpoints had this checkmark.Waterlog
P
19

Have you set the debuggable flag in the AndroidManifest? If you miss that, do so by adding android:debuggable="true" in the application tag. It should look like that in the end:

<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
Pentaprism answered 14/3, 2011 at 0:12 Comment(8)
And in the my case it won't help :-(Monochromatism
@Wooff you should post that as a separate answer. :)Doan
@Wooff as if I don't have enough files littering my dev folder. Are you saying I need another "debug" folder. I think Linux would be a more maintainable solution.Yate
Android Studio does not support this flag anymore.Hangdog
@ZdravkoDonev debuggable flag is now defined in build.gradle (see developer.android.com/studio/build/build-variants#build-types)Cassaba
@Monochromatism have you founded any solution?Threeply
@BhunnuBaba Yes, reinstalling Eclipse. Weaker solutions are: workspace cleaning (remove all eclipse file and import from the resulting project; Clean Project, Restart Eclipse.Monochromatism
I tried the solution but the android studio won't let me and shows me the message Avoid hardcoding the debug modeLafountain
T
16

In my case, click the "Attach debugger to Android process"

And it will shows a window said "Choose Process" Select the device you are using, and select the project that you want to debug. And it works.

Sometimes the debugger need to re-attach to the devices when you open the debugger at the first time.

Tibbetts answered 5/2, 2018 at 4:14 Comment(0)
D
10

For Android Studio:

  • Check if the option Mute Breakpoints is enabled by mistake. The icon looks like this:

Android debug toolbar

For Eclipse:

  • Check if the option "Skip All Breakpoints" is enabled by mistake. It is the last icon on the following toolbar skip-all icon

eclipse toolbar

Daryl answered 25/5, 2015 at 9:35 Comment(2)
Where can I find this option in android studio?Anklet
In Android Studio, "Mute Breakpoints" option is present inside Debug view. Check my edited answer.Daryl
A
5

Did you do "Debug As --> Android Application" instead of "Run As"?

Only if you do "Debug As", eclipse will stop at breakpoints.

Aestival answered 9/8, 2013 at 17:46 Comment(0)
C
3

I had the same problem. Go to build.gradle. You must change this code if you have one.

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

The debug section should look like this:

buildTypes {
    release {
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

I hope your problem is solved

Crimpy answered 8/9, 2021 at 5:34 Comment(0)
C
1

In my case, the app created a service with a different process with android:process=":service" in the AndroidManifest. So I was setting breakpoints in the service process code while the debugger is automatically attached to the main app process. Pretty stupid of me but it might help someone else.

You attach to the service process with Run > Attach Debugger To Android Process and choose the service process. You might need to add android.os.Debug.waitForDebugger(); to your service process code if you can't attach in time manually.

As far as I know, there's no way to automatically tell Android Studio or IntelliJ to attach to a different process before running.

Crenel answered 26/3, 2020 at 22:42 Comment(0)
I
1

if you have added some build type in build.gradle check to have debuggable true

buildTypes {
    debug {
        debuggable true
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    } 

    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
Imagine answered 5/4, 2020 at 8:16 Comment(1)
I had no debug config but adding one like the above solved my problem.Percaline
E
0

i had this problem i clean buildTypes part of build.gradle and try age so it work me.

Edelstein answered 19/2, 2021 at 18:28 Comment(0)
C
0

If you are finding this issue while using the Flutter plugin, you can try updating the plugin to version >65.1.3 as specified in this article

Cummine answered 22/3, 2022 at 19:9 Comment(0)
E
0

None of the valid answers above worked for me. In my case there was another app still in the background that I had launched some time earlier via Android Studio. So not the same App/PackageId, but another. After closing that app I got hits on breakpoints via wifi debugging.

Epicenter answered 12/11, 2022 at 18:51 Comment(0)
I
-1

I had the same issue and resolved it by increasing the debugger timeout values. The emulator is slow as a dog on my Dev box and that is what prevented the debugger to catch and stop on breakpoints. I changed the timeout values respectively from 3000 to 10000 and 20000 to 60000 and all is fine now.

V.

Ilailaire answered 11/7, 2013 at 16:38 Comment(1)
Where do you set the debugger timeout values? I think I have the same problem as you, because the debugger catches on every breakpoint when I debug on a physical device, but most often fails to catch on the first breakpoint I set when I debug on the emulator. -SarahImplicatory

© 2022 - 2024 — McMap. All rights reserved.