How to debug and track Android source code

Source: Internet
Author: User
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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.