Android programming: debugging method, android programming
Learning knowledge: debugging methods for Android
=== Debugging method ===
Prerequisites: The IDE environment is Android Studio. You are familiar with LogCat and know how to view log information.
Tool: Android DDMS debugging tool. You can click a crawler-like icon to start the interface and enter the debugging mode.
Device monitoring tool: Android Device Monitor (menu: tools-> android-> Android Device Monitor)
Android Device Monitor is used to view information about Android devices. Information type:
1. Thread Information
2. HEAP memory
3. Memory Allocation tracking statistics
4. network usage
5. File structure information
6. Simulated Control
7. system running information
All the above things must be understood. These are just tools and basic tools that will be updated, changed, or changed with the IDE development environment.
However, changes do not focus on these issues. However, debugging requires restarting the ADB service to allow the ADB service to support debugging. The important content is the debugging method:
1. Check the stack tracing information reported by LogCat to locate the problem.
: Throws an exception for common errors, such as null pointers.
2. Use the Log class to print Log information in key code locations for troubleshooting
: For common logical errors, such as forgetting to update a status: Next or last?
3. Use breakpoints to outline the Business Process processing trend of code step by step, so as to help you understand where business errors occur
: For obscure problems, it is mainly a BUG with strong logic relevance.
4. Check the code, clear the business process, and assist in the identification of problem codes by means of Binary Division and Division.
: This type of BUG is hidden, or occasionally discovered, or the product software has been released. It can only be located based on the description and symptom of some logs or feedback.
I have used many binary methods and exclusion methods, and they are used to solve problems efficiently and scientifically during debugging. For example, if your program
It consists of three modules: A, B, and C. Based on the log feedback, you find an exception message or problem description, which can be excluded from modules A and C.
Output, it is determined that it is caused by Module B. However, when an exception is found, Module B has several places. In this case, the scope of this field needs to be defined by the binary method.
Reduce, first divide the code of Module B into two parts according to the execution logic, eliminate one part, continue to eliminate the same ideas of the problematic code, and gradually
Approaching the problematic code!