Android development environment Build and compile

Source: Internet
Author: User

Two ways to build the environment, one way is to install the virtual machine, and then install the basic Ubuntu12.04.2 system, using the tools provided and detailed use of the steps to build a compilation environment, the other way is to install the virtual machine, and then directly loaded "set up the Ubuntu image", Users only need to modify the compiler environment variables, you can directly use to compile the source code.

Steps to build your environment:

1.1 Install basic software

Install the virtual machine "VMWARE_WORKSTAION_WM" first, and then use the virtual machine to install "Ubuntu12.04.2 initial system". Virtual machines and Ubuntu Initial system WebEx provides downloads for electronics on the network disk. Ubuntu installation method can refer to the 3.2 section to install the Ubuntu12.04.2 original system. After installation, go to Ubuntu terminal, activate the root user, the following:

In the Ubuntu command line, execute the following command: sudo passwd root

Then in the Ubuntu terminal to enter the installation password and the new password, Ubuntu system password is hidden by default. Then log in to the root user, as follows: On the Ubuntu command line, execute the following command: Su root

Then enter the password, you can log on to the root user. All subsequent operations need to be performed under the root user. Then install the software vim and ssh in Ubuntu, as follows: On the Ubuntu command line, execute the following command:

Apt-get Install Vim

Apt-get Install SSH

The above installed SSH software, can be very convenient to transfer files on the host and virtual machine, you can also control the Ubuntu system through the remote terminal, recommended for everyone to use. The use of SSH software is referenced in section 3.3.

1.2 Install the compilation component

Cross-compilation tool

Compile the need to use the cross-compilation tool, we provide the cross-compiler tool is the user CD "Tool-chains" folder "arm-2009q3.tar.bz2" Copy the cross-compiling tool to the Ubuntu12.04.2 system folder "USR"-- > "Local"--"arm", then unzip the package into the current directory on the Ubuntu system.

Modify the path of the cross-compilation tool (modify environment variables)

To modify the cross-compilation tool path, you need to modify the environment variables as follows:

In the Ubuntu command line, execute the following command:

Cd/root

Vim. BASHRC

Then add the following information in the last line in the ". BASHRC" File:

Export path= $PATH:/usr/local/arm/arm-2009q3/bin

Save exit after the modification is complete.

Update the environment variables by executing the following command

source. BASHRC

Finally, enter the command "arm" in the Ubuntu command line and press the TAB key, if you can see the information of the arm compiler on the command line, the cross-compilation tool installation is successful.

1.3 Install library files, JDK, and reduce GCC versions

We made the library file and the JDK installation command into a script file that allows the user to install the library file and JDK with just two scripts. The two scripts in the User CD Tools folder under the compressed package "Android_JDK.tar.bz2", the user copies the compressed package to the Ubuntu system, the decompression package will generate folder "ANDROID_JDK".

Install library files and JDK

Using the CD command, go to the extracted "android_jdk"--"Jdk6" folder and run the script file "install-sun-java6.sh".

Here's how to do this: on the Ubuntu command line, execute the following command:

./install-sun-java6.sh

It is important to note that this command will take more than 15 minutes to complete. Go to the extracted folder "ANDROID_JDK" Run the Script "install-devel-packages.sh", install the library file, the following: in the Ubuntu command line, execute the following command:

./install-devel-packages.sh

It is important to note that this command will take more than 40 minutes to complete.

It is important to note that when the above script finishes executing, note that some library files are not installed. If you find that a library file is not installed, it is possible that the network is bad or the download source is missing. This time the user uses the command "Apt-get update" to update the download source and then executes the above two scripts.

Lower GCC version

Compiling Android4.0.3 using Ubuntu requires the GCC4.4.7 compiler that comes with the Ubuntu system, but the installed version of Ubuntu12.04.2, which has a GCC version that is too high, will need to reduce the GCC-compiled version to 4.4.7. Into the folder "Android_jdk" extracted in front, you will see a text "Update_gcc.txt", open the text "Update_gcc.txt" will see there are 8 commands, these 8 commands need to be executed in sequence on the Ubuntu command line. After executing these 8 commands, the Ubuntu system lowered the GCC version to 4.4.7. It is important to note that when you execute these 8 commands, only the first command will take about 10 minutes, the rest will be completed quickly, and the command will be executed in sequence, without omission.

2 Android4.0.3 Compilation of Images

2.1 Uboot the compilation

Uboot source in the user CD "Android source" folder in the compressed package "iTop4412_uboot_xxx_xxx.tar.gz" in. Copy the compressed package to Ubuntu system and generate the Uboot source folder "Itop4412_uboot_xxx" after decompression. Compiling uboot also requires a tool folder "Codesign4secureboot", which is in the user CD "Android source" folder. This tool folder needs to be extracted from the previous folder Uboot source folder in the same directory.

Then you can compile, enter the Uboot source folder, compile Uboot, the specific operation is as follows:

In the Ubuntu command line, execute the following command:

./create_uboot.sh

When the compilation is complete, the uboot image file "U-boot-itop-4412.bin" is generated in the Uboot source folder.

2.2 Linux compilation of the kernel

Linux Kernel source code in the user CD "Android source" folder of the compressed package

"Itop4412_kernel_3.0_xxx.tar.gz". Copy the source compression package to Ubuntu system, after decompression to generate the Linux kernel source folder "itop4412_kernel_3.0". Enter the Linux kernel source folder and compile the Linux kernel with the following details:

In the Ubuntu command line, execute the following command:

Make

After compiling, the image file "Zimage" is generated in the source folder "Arch"--"arm" and "boot" folder.

2.3 Android4.0.3 the compilation

Android4.0.3 of the source code in the user CD "Android source" folder of the compressed package

"ITop4412_ICS_xxx.tar.gz". Copy the source compression package to Ubuntu system, extract the Android4.0.3 source folder "Itop4412_ics". Also need to put the previous section of the kernel source "itop4412_kernel_3.0" and Android Source "Itop4412_ics" two folders under the same directory. Note: To compile the kernel "itop4412_kernel_3.0" first, then compile "itop4412_ics". Compile the Android4.0.3 with the following details:

Go to the folder "Itop4412_ics", in the Ubuntu command line, execute the following command:

./build_android.sh

After compilation is completed in the folder "Itop4412_ics"-"out"-"target"-"product-->" smdk4x12 "

The Android4.0.3 image file "ranmdisk-uboot.img" and "system.img" are generated in the

It is important to note that the first compilation takes a long time and is related to the amount of memory allocated to Ubuntu by the virtual machine and the hardware configuration of the CPU. If you allocate only 512 memory, the compilation time may reach more than 4 hours, so the machine allows you to allocate as many resources as possible to speed up the compilation. In addition, after compiling the Android4.0.3, plus the source code and compiled intermediate files, almost occupy 18 g space.

There is also a command to clear the command "make clobber". After the purge command is executed, many of the intermediate files will be purged. If you clear the intermediate files to compile Android again, the intermediate files need to be compiled again, the compilation of intermediate files will take a long time. In general, you do not need to execute the purge command, if you do not perform the cleanup, compile Android again, the compilation system will intelligently identify those that have not changed the source files, eliminating the process of generating intermediate files, which will greatly reduce the compile time.

3 Android4.2.2 Building and compiling the environment

3.1 Uboot the compilation

The Uboot and Android4.0.3 systems of the Android4.2.2 system are uboot generic.

3.2 Linux3.5 compilation of the kernel

Since compiling the linux-3.5 kernel requires the use of a cross-compiler with the Android4.2.2 source, you need to copy the Android4.2.2 source to the Ubuntu virtual machine. For example, the Android4.2.2 compressed package "android-4.2.2_r1_xxxxxxxx.tar.gz" (downloaded from the network disk, XXXXXXXX is the version date) copied to the Ubuntu virtual machine "/home/topeet/ Android "directory, using the command" TAR-XVF android-4.2.2_r1_ xxxxxxxx.tar.gz "decompression Android4.2.2 source, extract the completion of the" ANDROID-4.2.2_R1 "folder. Next, Android4.2.2 's kernel compression package "itop-4412_kernel-3.5_xxxxxxxx.tar.gz" (downloaded from the network disk, XXXXXXXX is the kernel version date) is copied to the Ubuntu system, using "tar- Xvfitop-4412_kernel-3.5_ xxxxxxxx.tar.gz "Unzip this tarball and generate the Linux kernel source folder" linux-3.5 ". Then use the "CD linux-3.5" command to enter the Linux kernel source folder, in the "linux-3.5" directory Found "Makefile" file, use the "vi Makefile" command to open this file, and then find the line containing the following:

"Cross_compile? =/home/cym/exynos4412/4.2/android4.2.2_jlb_pc4_cyit/pre

builts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-"modified to the directory in which the previous Android4.2.2 is stored:" CROSS_ COMPILE? =/home/topeet/android/android-4.2.2_r1/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/ arm-linux-androideabi-"Here means setting the path of the cross-compiler, exiting and saving the makefile file after the modification is complete. Next, start compiling the Linux kernel, and execute the following command in the "linux-3.5" directory to start compiling the kernel:

Make

After compiling, the image file "Zimage" is generated in the source folder "Arch"--"arm" and "boot" folder.

3.3 Android4.2.2 the compilation

In the 5.4.2 section, the Android4.2.2 code has been copied to the Ubuntu system, and the extract generated

"Android-4.2.2_r1" folder, and then use the "#cd android-4.2.2_r1" command to enter the Android4.2.2

Source directory, enter the following command to start compiling Android4.2.2:

./create.sh

When the compilation is complete, the image file is generated under "out/target/product/smdk4412" in the current directory:

Ramdisk-uboot.img

System.img

4 Android4.4.4 Building and compiling the environment

The Android4.4.4 compilation environment is exactly the same as the Android4.0.3 compilation environment. Uboot and the kernel version is the same, if the user compiled Android4.0.3, then Android4.4.4 will be easy to compile. The method of burning and writing is exactly the same as Android4.0.3. The user can download the source tarball to Android4.4 in the network disk. After decompression can get Android4.4.4 and kernel source.

4.1 uboot the compilation

Android4.2.2 's uboot is compiled in the same way as Android4.0.3.

4.2 Linux compilation of the kernel

The Android4.4.4 kernel uses a version of 3.0.15, which is the same as the kernel version of Android4.0.3. After extracting, get the folder "itop4412_kernel_3.0" and enter the folder as shown in.

The compiler is also using the "ARM-2009Q3". If the compiler is not the default in an environment variable, then you need to modify it as shown, and remember to use the command "source. BASHRC" To update the environment variables.

Then use the "make" command to compile the kernel. For example, the compilation is complete.

Generate the Mirror "Zimage" in the "Arch/arm/boot" folder.

4.3 Android4.4.4 the compilation

Users use the built-in build environment that WebEx provides for electronics, and if they can compile through Android4.0.3, then Android4.4.4 's compilation is simple. First of all, the corresponding kernel files and Android files to the same level directory, such as the blue box is the kernel and the Android source folder.

Compile Android4.4.4, also missing a "JAVAP" command, as shown, using the command "Update-alternatives--INSTALL/USR/BIN/JAVAP JAVAP usr/lib/jvm/jdk1.6.0_43/ Bin/javap

300 "update.

Then enter the Android4.4.4 source extracted after extracting the folder "itop4412_kk4.4", using the command "./build_android.sh", run the one-click Compile script, start compiling Android4.4.4.

As shown, the compilation is complete. In the folder "itop4412_kk4.4/out/target/product/smdk4x12", generate the Mirror "ramdisk.img" and "system.img".

It is also important to note that the Android4.4.4 source code needs to occupy a larger space, the user needs to confirm that there is enough space to be able to compile successfully. Android4.0.3 compiled after the completion of a total of about 18G space, Android4.4.4 compiled after the completion of a total of about 36G space, such as.

The user completely follows the steps to compile the error, you can use "df-l" to see how much of the remaining space is left, as shown, if you have used 100%, there is insufficient space.

Android development environment Build and compile

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.