Java (Android Studio) 如何仅通过我的代码进行调试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19486163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(Android Studio) How to debug through my code only?
提问by user1406716
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.
当我尝试在 Android 中调试我的代码时(使用 Step Into、F7 命令),调试器会带我浏览所有我不想要的系统类。
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.
例如,当我在下面的第 2 行(即“startActivity(ourIntent);”)放置断点时,执行点不是进入我的 Activity(即“myclass)”,而是进入 Activity.java > Instrumentation.java 等...所有系统类。
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
“调试器”>“步进”下的“添加新模式”选项被禁用
采纳答案by Adam Johns
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.
转到Android Studio > Preferences > Debugger > Stepping
然后在底部单击带有问号的加号箭头Add Pattern
。输入android.*
并点击确定,然后应用。
回答by Alex
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.
除了 Adam Johns 对忽略 Android 库的回答之外,您还可以使用“Step Over”按钮 (F8) 来跳过您不感兴趣的方法调用,例如来自您导入的任何其他库。
回答by Sahil Sharma
Use f9 (Resume Program). This will Resume your Program and stop only to the next Break Point.
使用 f9(恢复程序)。这将继续您的程序并仅停止到下一个断点。
回答by Silver Sagely
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.
在 Android Studio 2.0 中,选择文件 > 设置 > 构建、执行、部署 > 调试器 > 步进。然后单击右侧的“添加图案”按钮。输入 android.*(或任何您想排除的模式)并单击“确定”两次。
回答by Tim Glenn
Shift-F11 to step out of the method helps too.
Shift-F11 退出该方法也有帮助。
回答by ostin
In Android 2.3.1 Go to Android Studio > Preferences > Debugger > Steppingthen 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.
在 Android 2.3.1 中,转到Android Studio > Preferences > Debugger > Stepping然后在底部单击带有点、星号和问号的加号箭头图标,即添加模式。输入 android.* 和 com.android.* 并单击 OK 和 Apply。
回答by Alen Lee
1. Add Custom Pattern
1. 添加自定义图案
Android Studio 3.x.x
安卓工作室 3.xx
Android Studio > File > Settings > Build,Execution,Deployment > Debugger > Stepping
Android Studio > 文件 > 设置 > 构建、执行、部署 > 调试器 > 步进
2. Step Over(F8)
2. 跳过(F8)
回答by beginner
For the latest version of android studios
对于最新版本的 android studios
- Go to
File->Setting
and search forStepping
- click on
+?
sign on the right side add the following 4 patterns one by one
com.android.*
android.*
com.androidx.*
androidx.*
- 前往
File->Setting
并搜索Stepping
- 点击
+?
右侧的标志 将以下4个图案一一添加
com.android.*
android.*
com.androidx.*
androidx.*