69

When I try to debug through my code in Android (using Step Into, F7 command), the debugger takes me through all system classes, which I do not want.

For example, when I place a breakpoint at the 2nd line below (i.e. "startActivity(ourIntent);"), instead of going into my Activity (i.e. "myclass), the execution point goes into Activity.java > Instrumentation.java, etc... all system classes.

I dont want that. I only want to step through my code that I have written.

What is a way to achieve this?

        Intent ourIntent = new Intent(MainActivity.this, "com.practice.gamesbook.myclass");
        startActivity(ourIntent);

"Add new Pattern" option under "Debugger" > "Stepping" is disabled

enter image description here

user1406716
  • 9,565
  • 22
  • 96
  • 151

8 Answers8

68

Go to Android Studio > Preferences > Debugger > Stepping then in the bottom click the plus arrow with the question mark that says Add Pattern. Type android.* and hit OK and then Apply.

Adam Johns
  • 35,397
  • 25
  • 123
  • 176
  • thanks - but i see that in my envt, the "Add New Pattern" button is disabled, cant click on it. Any idea why that may be? – user1406716 Oct 24 '13 at 23:51
  • 1
    @user1406716 I've found that sometimes when using the search feature within Settings (in your example above, you've typed "Debugger") that some options in the pane on the right are disabled. Clear the filter search ("debugger" text), manually navigate Debugger->Stepping, then try. The read-only status of the controls should clear. – CJBS Sep 09 '14 at 17:10
  • 8
    With pattern, android.* you might also include com.android.* – Muhammad Oct 13 '14 at 08:16
  • 8
    where is that "Android Studio > Preferences" option? I see "File, Edit, View, Navigate, Code, Analyze, Refactor, Build, Run, Tools, VCS, Window, Help" – barlop Feb 16 '15 at 00:12
  • I see it now(file..settings). I've also added besides android.* also, dalvik.* and com.android.* just checking the package headers of classes it was going through any time I saw it going through classes I didn't write/didn't want it to, and using patterns of those ones. – barlop Feb 16 '15 at 01:13
  • 3
    In AS 2.0 debug options are under Preferences > Build, Execution, Deployment > Stepping – lm2a Dec 08 '15 at 12:05
  • is there any way to pop debugger in case of a condition? – Mahdi Oct 31 '16 at 11:21
  • 6
    @barlop File > Settings > Build, Execution, Deployment > Debugger > Stepping – Sudip Bhandari Dec 13 '16 at 13:23
23

For the latest version of android studios

  1. Go to File->Setting and search for Stepping
  2. click on +? sign on the right side
  3. add the following 4 patterns one by one

    com.android.*

    android.*

    com.androidx.*

    androidx.*

beginner
  • 2,366
  • 4
  • 29
  • 53
  • I have added all these and even *.java. And I still run into java files that I didn't write. Is there anything I missed? I use kotlin. – Spidey May 17 '22 at 00:56
  • Hello, I think It should work for Kotlin, not sure why It didn't work for you. please try adding `.*\.java` (i think it will skip all the java files). just a wild guess. – beginner May 19 '22 at 13:26
  • For Kotlin, I also added `kotlinx.*`. I find it very odd to have to do this manually - I already have "Do not step into Kotlin runtime library implementation classes selected"... – Ctrl-Zed Feb 28 '23 at 18:06
17

In Android Studio 2.0 select File > Settings > Build, Execution, Deployment > Debugger > Stepping. Then click the "Add Pattern" button on the right. Type android.* (or whatever pattern you want to exclude) and click "OK" twice.

Silver Sagely
  • 404
  • 1
  • 5
  • 10
8

In addition to Adam Johns's answer for ignoring the Android libraries, you can use the "Step Over" button (F8) to step over a method call the details of which you're not interested in, such as from any other library you import.

Alex North
  • 1,189
  • 13
  • 12
8

Use f9 (Resume Program). This will Resume your Program and stop only to the next Break Point.

Sahil Sharma
  • 117
  • 1
  • 4
3

Shift-F11 to step out of the method helps too.

Tim Glenn
  • 224
  • 2
  • 8
3

In Android 2.3.1 Go to Android Studio > Preferences > Debugger > Stepping then in the bottom click the plus arrow icon which has dot,star and question mark which is Add Pattern. Type android.* and com.android.* and click OK and Apply.

ostin
  • 31
  • 1
2

1. Add Custom Pattern

Android Studio 3.x.x

Android Studio > File > Settings > Build,Execution,Deployment > Debugger > Stepping

2. Step Over(F8)

Community
  • 1
  • 1
Alen Lee
  • 2,479
  • 2
  • 21
  • 30