Android ubuntu9.10 source code compilation Eclipse project contacts compilation application loading

Source: Internet
Author: User

Part 1: Installation and compilation of the compiling environment

1. Install ubuntu9.10 System

2. Upload the source code to Ubuntu and decompress it.

3. Install the compiling environment

A. sudo apt-Get install bison

B. sudo apt-Get install Vim

C. Solution: Install JDK 5.0

1): According to the official document,Source codeJdk5 is required for compilation. Therefore, we use jdk5

2): update the source and run sudo Vim/etc/APT/sources. List on the terminal.

3): copy the following two lines to the end of the document in source. List:

Deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse

Deb http://us.archive.ubuntu.com/ubuntu/ jaunty-Updates multiverse

Save and exit.

4): Execute sudo apt-Get update to update the source.

5): configure the compiling environment and download the jdk5: sudo apt-Get install sun-java5-jdk

D. sudo apt-Get install build-essential

E. sudo apt-Get install zlib1g-dev

F. sudo apt-Get install flex

G. sudo apt-Get install libncurses-Dev

H. sudo apt-Get install libx11-dev

I. sudo apt-Get install gperf

4. Set Environment Variables

VI ~ /. Bashrc

# JavaProgramDevelopment/running environment variables

Java_home =/usr/lib/JVM/Java-1.5.0-sun

Jre_home =$ {java_home}/JRE

Export android_java_home = $ java_home

Export classpath =. :$ {java_home}/lib: $ jre_home/lib: $ classpath

Export java_path =$ {java_home}/bin: $ {jre_home}/bin

Export java_home;

Export jre_home;

Export classpath;

Home_bin = ~ /Bin/

Export path =$ {path }:$ {java_path }:$ {home_bin };

# Java program development/running environment variables

Export android_product_out = $ androiddir/out/target/product/generic

Android_product_out_bin = $ androiddir/out/host/linux-x86/bin

Export path =$ {path }:$ {android_product_out_bin }:: {android_product_out };

Save and exit, and then execute source ~ /. Bashrc synchronization Source

Note that $ androiddir is the directory of your android source code.

5. In the source code project directory make, wait...

Start the simulator

. Build/envsetup. Sh

Emulator &

If the simulator window is displayed, the compilation is successful.

 

Part 2: module compilation in the source code directory

A. Compile the SDK

# Make product-SDK

After the SDK is compiled, in the out/host/linux-x86/SDK/android-sdk_eng.xxx_linux-x86, pay attention to remove it, it is better to clear it next time Mmm Compilation

B. Compile the application module: less contact

. Build/envsetup. Sh

Mmm packages/apps/contacts

$ Make Snod

Regenerate system. IMG and run the simulator: emulator &

 

// Not required. It can be created through the Eclipse project

C. Create an android Virtual Device

The compiled SDK does not have AVD (Android Virtual Device). You can view it using the android tool:

$ Android list

Create AVD:

$ Android create AVD-T 1-N myavd

You can use Android-help to view the usage of the preceding Command Options. There are some options in the creation, the default is enough

Run the android LIST command to view the location where AVD is stored.

The-AVD myavd or @ myavd option will be added for every running of emulator in the future:

$ Emulator-AVD myavd

 

Part 3: Build an eclipse environment eclipse

1. Download eclipse

Sudo apt-Get install eclipse

2. Download the ADT and restart it.

A. Start eclipse, and select help> Software Updates> Find and install ....

B. When the dialog box appears, select search for new features to install and click Next.

C. Click new remote site.

D. In the result dialog box, enter the name of the remote site (for example, Android plugin) and enter the site as follows:

Https://dl-ssl.google.com/android/eclipse/site.xmlclick OK.

3. Load the SDK

A. Select WINDOW> preferences... To open the properties Panel. (Mac OS X: Eclipse> preferences)

B. Select android from the left-side navigation pane.

C. Locate the SDK on the main interface and Click Browse... Then locate the SDK folder.

D. Click Apply and then click OK.

4. Create an android project to debug the application.

 

Part 4: load the android source code as the Eclipse project and debug it

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

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

3. In the Eclipse project menu window --> preferences --> JAVA --> code style --> formatter import android-formatting.xml file, organize imports import Android. importorder File

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

5. Modify the eclipse configuration, which is located in the eclipse. ini file under the Android. importorder directory. Modify-XMS,-xmx to 128 and 512.

-Xms128m

-Xmx512m

Debugging:

1. Exit the Eclipse project

2. Run. Build/envsetup. Sh In the android source code directory.

3. Start emulator &

4. After the simulator is started successfully, start ddms &

5. Select a process. Be sure to select

6. Start eclipse and configure debugging information.

 

7. set breakpoints and start debugging.

Part 5: add an app as an Android app

1. Develop your own Android Application under the SDK directory of the same version as the system

2. Put the developed Android project under the packages/apps/directory of the source code.

3. Add the Android. mk file in the project directory, modify local_package_name: = test001, set the project name to your project name, and the project I load to test001.

Local_path: = $ (call my-DIR)

Include $ (clear_vars)

 

Local_module_tags: = user

 

Local_src_files: = $ (call all-Java-files-under, Src)

 

Local_static_java_libraries: = googlelogin-Client

 

Local_package_name: = test001

Local_certificate: = shared

 

Include $ (build_package)

 

# Use the folloing include to make our test APK.

Include $ (call all-makefiles-under, $ (local_path ))

4. Return to the source code directory and execute. Build/envsetup. Sh. Note that there is a space behind Sh.

5. Run Mmm packages/apps/test001 to compile the test001.apk package.

6. Execute make Snod and compile the system. IMG package.

7. Execute emulator and you will be able to see the project you have compiled in the application.

 

Part 6: how to modify the Contact application based on the android source code and add your own activity

1. Create an android project and load your own java files and resource files.

2. After the preliminary debugging of your android project is successful, copy the Java file and resource file of the project to the corresponding Java file and resource file directory of the contact.

3. Then, run the following command in Linux to compile the contact module and compile the resource file into the contact directory.

. Build/envsetup. Sh

Mmm packages/apps/contacts

4. Refresh the android source code project. At this time, you can view the newly added resource files and source files in the contacts package directory, and modify them under the source code project.CodeAnd directly debugged

5 .?? Why not add source files and XML resource files directly under the android source code project ????

A: Because our android source code engineer imported it using a Java project, if the android XML file is added, the Java program cannot identify the resource R file, so we must first

XML resource files are first compiled in Linux

6. after modifying the source code project, you can execute the contact compilation command again in Linux and make Snod to load the system. imgfile, and start the emulator &) to view your modifications.

 

Part 1: Basic Structure of the contacts Application

Main portal program: dialtactsactivity. Java

Start function:

Protected void oncreate (bundle icicle ){

Super. oncreate (icicle );

 

Final intent = getintent ();

Fixintent (intent );

// Hide title

Requestwindowfeature (window. feature_no_title );

Setcontentview (R. layout. dialer_activity );

/* Initialize the tab Layout */

Mtabhost = gettabhost ();

// Set the tab Change Notification

Mtabhost. setontabchangedlistener (this );

 

// Set the dial Tab

Setupdialertab ();

// Set the call log Tab

Setupcalllogtab ();

// Set the contact Tab

Setupcontactstab ();

// Set the favorite Tab

Setupfavoritestab ();

// Set the tab page currently displayed

Setcurrenttab (intent );

 

/*???? */

If (intent. getaction (). Equals (ui. filter_contacts_action)

& Icicle = NULL ){

Setupfiltertext (intent );

}

}

By zhangweia 07/19.

 

 

 

 

 

 

 

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.