Android Survival Guide: A detailed explanation of the problem of solving bug strategies and ideas _android
Source: Internet
Author: User
Now the need to maintain and customize Android more and more, do more and more people, and Google directly released the source code has a lot of bugs and unreasonable places, especially native applications, such as Mms,browser, Email, contacts and so on. The first step in customizing or doing the Android solution is to fix the native bugs to get a stable system.
1. Carefully observe the characteristics of the bug Understand the processes and modules involved in bugs, and what kind of bug,exception? Functional? or the Ui/ue design problem. For different problems, may have to take different means, for exception must first analyze the log file to determine the cause of exception; For functional problems, you may want to try to reproduce first; for ui/ue problems, you might want to first find the UI designer to confirm whether you need to change it.
2. Identifying determinants, excluding secondary and irrelevant factors Analyze, refine, and attempt to reproduce to exclude secondary, unrelated factors and procedures. If you are concerned with certain data, you need to disassemble the data to remove the unaffected part until you find the special data that caused the problem.
3. Compare Compare it to the normal process and compare it with the version that is not in question, and compare it with a series of products to see what anomalies and inconsistencies are.
4. Principle of single variable Change one thing at a time so that you know what's wrong or what's going on. If there are two simultaneous changes, it is difficult to tell which one has the effect.
5. Divide and conquer Through the division of the approach to gradually narrow the scope, first in a module analysis, determine the problem or no problem, and then go to its module, first in one of the logic or file analysis, and then to other, to avoid blind confusion.
6. Simulation scene Use special data, or modify the code to simulate the scene when the bug occurs. This is especially useful for reproducing a bug that is not required, and is also useful for threading problems.
7. Approach to positioning problems: experience +log+debugging Tools Experience is gained by accumulating, and often people who are familiar with code and process are positioned much faster; Log is a simple, crude way of logging and printing; The debugging tool is a breakpoint Single-step tool like Eclipse and GDB. Usually with experience and log for a wide range of positioning, when the process has a certain understanding, and has been positioned to a slightly smaller range, such as a function or a file within the tool can be used for breakpoints and single step debugging to accurately locate. When the scope is very large, such as the use of debugging tools will be very slow, it is difficult to find an effective breakpoint, single step is too cumbersome, it is easy to confuse and lost ideas.
8. Reverse Reasoning and insight The reverse reasoning force is important in debugging a bug, because you get a result (a bug), and to find out why, you need to reason and guess where the problem may be. Another very important ability is insight, log, operation, attention to some subtle differences, find some hidden clues, and so on. Of course, this is different from experience, it is not so easy to cultivate!
9. Specific methods and tools A. Compiling Obviously, want to use the method such as log, need to revise source code, add a log, need to compile. Overall build Android can use make, the whole compiled once after the local compile, into a directory with android.mk files run mm can be compiled into the directory apk, jar or so
B. Run After compiling, you should run the newly compiled apk or jar or so to see the difference. You can push Apk,jar and so through the ADB to the phone (apk to/system/app, jar to/system/framework, so to/system/lib). Or regenerate the system.img with the mm Snod command, and then use it (the emulator can do this).
c. Debugging Tools APK can be directly tuned with eclipse, if you want to compile
The jar will also be debugged with Eclipse.
So because all are native C/s + + code, you need to use GDB to debug. Mobile phone running on the GDBSERVER,PC with GDB Debug compiled symbols/the following library, GDB and Gdbserver used the phone to specify the port to communicate.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.