Debugging is the key process of finding and fixing bugs or unexpected behavior in your code. All code has errors, from incorrect behavior in your app to behavior that highly consumes memory or network resources, to actual app freezing or crashing.
调试是发现并修复代码中的错误或意外行为的关键过程。 所有代码都有错误,从应用程序中的错误行为到大量消耗内存或网络资源的行为,到实际的应用程序冻结或崩溃。
Debugging is one of the crucial parts of a software developer’s everyday life. We always attempt to write bug-free applications but to do this, we have to fix every bug, which is sometimes hard to spot in the code. Debugging allows you to go through each line of code, evaluating your app’s variables, methods and how well your code is working. It’s easier to find small mistakes in large pieces of code. In this article, we will go through important tips and tricks on debugging an Android app.
调试是软件开发人员日常生活的关键部分之一。 我们总是尝试编写无错误的应用程序,但是要做到这一点,我们必须修复每个错误,有时很难在代码中发现它们。 通过调试,您可以遍历代码的每一行,评估应用程序的变量,方法以及代码的运行状况。 在大型代码中发现小错误更容易。 在本文中,我们将介绍调试Android应用程序的重要提示和技巧。
Log filtering/folding
日志过滤/折叠
Conditional breakpoints
条件断点
Dependent breakpoints
相关断点
Suspend thread
挂起线程
Evaluate and log
评估并记录
Breakpoint groups
断点组
Drop frame
落架
Evaluate expression
评估表达
Apply changes
应用更改
Analyze stack trace
分析堆栈跟踪
Log filtering / folding
日志过滤/折叠
If we open up Logcat in Android Studio, we are seeing these things on that Logcat surfaces.
如果我们在Android Studio中打开Logcat ,则会在Logcat表面上看到这些东西。
![Image for post](https://miro.medium.com/max/9999/1*--BSK9hemrVWGNytU1HLXQ.png)
Show date and time with seconds: 1517955388.555 123–456, process and thread IDs: SampleTag, package name: com.android.sample and show tag: This is a sample message
显示日期和时间与秒:1517955388.555 123-456,进程和线程ID:SampleTag,包名:com.android.sample和显示标签:这是一个示例消息
In most cases, we don’t need date and time, package name and thread IDs. So to do that we can uncheck these options and we can view what are necessary.
在大多数情况下,我们不需要日期和时间,程序包名称和线程ID。 因此,我们可以取消选中这些选项,然后查看所需的内容。