Eclipse Android source code engineering debugging

Source: Internet
Author: User

Eclipse AndroidSource code engineering debugging is the content to be introduced in this article, mainly to understand and learnEclipse AndroidThe content of the source code.Eclipse AndroidFor more information about the source code, see this article.

1. Compile the source code in ubuntu

It is best to switch to the root user for operations

 
 
  1. $ sudo -s 

1) download and install jdk1.5 (download the self-decompressed version and set the environment variables)

Edit/root/. bashrc add

 
 
  1. #set java environment  
  2. export JAVA_HOME=/work/jdk1.5.0_22  
  3. export JRE_HOME=JAVA_HOME/jre  
  4. export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH  
  5. export SDK_HOME=/work/froyo/out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86/tools  
  6. export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH:$SDK_HOME:/work/froyo/out/host/linux-x86/bin  
  7. export ANDROID_PRODUCT_OUT=/work/froyo/out/target/product/generic 

2) install (apt-get install xxx)

 
 
  1. git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev 

3) download the source code (detailed instructions on the Internet)

4) Compile the source code

 
 
  1. $ export ANDROID_JAVA_HOME=$JAVA_HOME  
  2. $ make 

Check whether there are any errors during the compilation process. Generally, there are no errors. If there is an error, it may be that a dependency package is not installed. Install the dependent package prompt and re-make

5) generate the sdk

 
 
  1. $ Make PRODUCT-sdk ### using make sdk, the R file cannot be automatically generated.

After compilation, the sdk is generated in the/work/froyo/out/host/linux-x86/sdk/directory.

6) check whether the compilation is successful after compilation.

 
 
  1. $. Build/envsetup. sh
  2. $ Emulator & // start the simulator. If it can be started successfully, the compilation is successful.

2. debugging in Android Eclipse

1) Copy development/ide/eclipse/. classpath to the source code root directory and modify. classpath.

Delete the following two rows

 
 
  1. <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar"/> 
  2. <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar"/> 

Add

 
 
  1. <classpathentry kind="lib" path="/work/froyo/out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar"/> 

2) modify it in eclipse

2.1) use create project from existing source to import froyo source code

2.2) Expand packages/providers/CalendarProvider/src

2.3) Expand the package: com. android. providers. calendar

2.4) Right-click the package com. android. providers. calendar

2.5) Select "new file"

2.6) in the dialog box, click "Advanced>" to see "Link to file in the file system" checkbox,

2.7) Check checkbox. Then "Browse..." is available.

2.8) Click "Browse... "button, select EventLogTags. java (e.g ., out/target/common/obj/APPS/CalendarProvider_intermediates/src/com/android/providers/calendar/EventLogTags. java)

2.9) Click OK

2.10) Click Finish (in "New File ")

3) Modify com. android. providers. contacts in the same way.

3. debugging

Modify the source code in IDE (eclipse) and compile and run it in shell.

Built-in compilation tools for source code

Execute. build/envsetup. sh In the Eclipse Android source code root directory, and then compile it through m/mm/mmm.

 
 
  1. - m:       Makes from the top of the tree.  
  2. - mm:      Builds all of the modules in the current directory.  
  3. - mmm:     Builds all of the modules in the supplied directories. 
 
 
  1. $ Cd/path/to/android/root
  2. $. Build/envsetup. sh
  3. $ Lunch 1 # initialize simulators, etc.
  4. $ Make/m/mm/mmm #
  5. $ Emulator & # you shoshould see a GUI picture of a phone
  6. $ Ddms & # debugging tool

1) modify the APK application: the application in packages can be compiled independently after modification. Run

 
 
  1. $. Build/envsetup. sh # Initialization
  2. $ Mmm packages/providers/ContactsProvider/
  3. # The. APK compiled with mm/mmmwill not be packaged into system. img. You need to manually package the system folder as system. img through make snod.
  4. # You can use make snod to package the module into system. img, or use adb install *. apk to install the module.

Note: After you use mmm packages/providers/ContactsProvider/compiled apk in the out/target/product/generic/system/app

In this case, use adb install out/target/product/generic/system/app/xxx.apk to install the apk you just modified and you will be able to see the modification effect on the simulator.

2) modify the framework: If the framework is modified in Contacts. java, you must re-compile the framework. Run

 
 
  1. $. Build/envsetup. sh # Initialization

# If you want to execute make update-api on the Internet, you can directly make PRODUCT-sdk to compile the modified framework into the sdk. # After the framework is compiled, the modified applications do not need to be compiled separately. 4 ~ 6 minutes

 
 
  1. $ Make PRODUCT-sdk # regenerate SDK 10 ~ 20 minutes.

Summary: The Eclipse Android source code project debugging is complete. I hope you can learn the Eclipse Android source code to help you.

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.