Android Eclipse source code engineering debugging

Source: Internet
Author: User
1. Build an Eclipse source code project

1, enter the development/ide/eclipse under the source directory, the android-formatting.xml
, Android. importorder,. classpath copy to the source code directory

Eclipse requires a directory list to search for Java files, called "Java
Build Path ", saved in the. classpath file [eclipse project configuration file, so that we can directly import the corresponding android source code file and JAVA package into the project]

Import the files under development/ide/eclipse so that Eclipse complies with the Android encoding style:

2. Grant the execution permission to chmod + x. classpath.

3. In the eclipse project menu
Window --> preferences --> java --> Code Style --> Formatter imports the android-formatting. xml file and organize imports the android. importorder File

4. Create a java project and import the android source code.

Note the following two points:

1) the newly created project must be a java project, not an android project. Otherwise, the android source code will be damaged (generally multiple files/folders are added ).

2) check before import. whether the files in classpath have corresponding files (folders) in the android source code. Otherwise, the android source code will be damaged (generally multiple files/folders are added ).

In general:

1. Use eclipse to edit code and check for errors.

2. If you do not compile or run the android source code program on eclipse, you can only compile the android source code through make (or mm or mmm) on the command line.

3. You can debug the android source code program on eclipse (Principle: eclipse uses the ddms server to debug on emulator), and can debug and breakpoint in one step.

5. Modify the eclipse configuration, and the eclipse. ini file under the eclipse directory. Modify-Xms,-Xmx to 128 and 512.
-Xms128m
-Xmx512m

The Android project is very large and may cause memory consumption of the Eclipse Java Virtual Machine during compilation. We can avoid this problem by modifying eclipse. ini. In ubuntu, eclipse. ini is located in the directory where eclipse is located.

Ii. debug the android source code

1. Exit the Eclipse project
2. Run. build/envsetup. sh In the android source code directory to initialize the environment variable.[Lunch 1 # to build the emulator]
3. Start emulator & [you shocould see a GUI picture of a phone]
4. After the simulator is started successfully, start ddms & [you shocould get a splufty debugging console]

5. Select the process you want to debug on ddms. Generally, if it is an application that comes with the debugging system, such as a contact, select the following process.

6. Open the Eclipse project and set the debugging port

Select your project, right-click the menu, select Debug AS-Debug configuration, select Remote JAVA Application, right-click the menu, and select NEW. The following view is displayed, and the Port is changed to 8700.

7. If the selected process appears after debug, the debugging is successful.

8. For example, debug the call function.

Select com. android. phone on DDMS.

Find the com. android. internal. telephony package under the frameworks/base/telephoney/java directory, and find the RIL. java file.

Set the breakpoint in the public void dial (String address, int clirMode, UUSInfo uusInfo, Message result) function.

Then, call the phone number in the simulator to stop at the set breakpoint and view the variable.

==========================================

Problems:

Project 'gingerbread' is missing required library: 'Out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib. jar'
Project 'gingerbread' is missing required library: 'Out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib. jar'

Solution:
Delete the path of the two rows in. classpath
<Classpathentry kind = "lib" path = "out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib. jar"/>
<Classpathentry kind = "lib" path = "out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib. jar"/>
Add
<Classpathentry kind = "lib" path = "out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib. jar"/>

<Classpathentry
Kind = "lib" path = "out/target/common/obj/JAVA_LIBRARIES/filterfw_intermediates/classes-jarjar.jar"/>

<Classpathentry
Kind = "lib" path = "out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/classes-jarjar.jar"/>

Brief description:

In the past debugging experience, the reader is used to using the Eclipse command menu run/debug to debug an independent Android Application. The Framework is not an application. How can he debug it? The following are some notes:

1. Although the Android Framework is the Android kernel, it also contains an application named system_process. The corresponding TCP port address is generally 8600, therefore, you can debug the program.

2. the SDK source code contained in the Framework has only one copy in the program space, but each application calls this part of the program, this code runs in the user process where the application is located.

Based on the above two points, in theory, you can debug common applications and attach the source code in the Android SDK to the debugging program. Then you can debug the source code of the Framework in one step. On the other hand, you can debug system_process separately.

Three debugging instances are described below:

1. Common application debugging:

Run/debug the menu command. When debugging to the place where the Framework code needs to be called, eclipse will prompt that the required Code cannot be found. At this time, you can click Attach Source on the prompt page... "button, and refer to our Android source code directory. Its function is to use the source file in Android as the android SDK. jar source code, so that you can run it in a single step to the corresponding Framework source code.

Ii. System Application debugging:

In packages/app/packages. To generate contacts.apk, you can use either of the following methods: Prepare or use make directly in Terminal.
Contactscommand to compile contacts.apk. The latter method is generally used.

Related Article

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.