There are a lot of code on the Android platform, and the relationship is also very complex. We usually cannot track the android framework code during program debugging, if you can debug and track the android source code, this article provides a method to debug and track the android source code.
1. first, get the android source code (reference previous article --if he has obtained the androidsource code and compiled the .doc), and compile it to get the output file. In the (Android source)/out directory, you can also get the android source code (androidsrc. tgz for example) and other compiled output file (Out. tgz)
2. decompress the two tgz files and put the extracted out directory under the myandroid directory, as shown in.
3. Copy myandroid/development/IDE/Eclipse/. classpath to myandroid/. classpath.
4. Copy myandroid/out/target/product/generic/*. IMG to {Android SDK}/tools/lib/images and overwrite the source file.
5. Run emulator.exe under the {Android SDK}/tools directory.
6. Run ddms. bat in the {Android SDK}/tools directory. You can see the following window, which lists the processes running in the current emulator:
7. Start eclipse and follow this step to file-> New-> JAVA Project (not an android project !) -> Create project from existing source: select the myandroid directory.
8. after a long wait, the android source code will be imported into the project. Normally, there should be no errors, but there will be a lot of warning. If there is an error, the debug will not succeed, the cause may be output file, out. an error occurred while extracting tgz. Copy out again. tgz, or copy the out/directory to the local directory.
9. Select the process to be debugged in ddms. Take the phone process as an example. ddms must be started before eclipse. Otherwise, a ddms will be started during eclipse startup, causing a conflict.
10. In eclipse, run-> debug configuration-> remote Java application-> New, set connection port to 8700 (ddms's default port, you can change it ).
11. Set the breakpoint in the source code, and then debug it as usual.