简体   繁体   中英

(Android Studio) How to debug through my code only?

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 (ie "startActivity(ourIntent);"), instead of going into my Activity (ie "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

在此处输入图片说明

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.

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.

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.*

除了 Adam Johns 对忽略 Android 库的回答之外,您还可以使用“Step Over”按钮 (F8) 来跳过您不感兴趣的方法调用,例如来自您导入的任何其他库。

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

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.

Shift-F11 退出该方法也有帮助。

1. Add Custom Pattern

Android Studio 3.xx

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

2. Step Over(F8)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM