3. Compile the android source code and toolkit
1. Compile the android source code
Go to the source directory and execute make.
After compilation, you can see the compiled ramdisk. IMG, system. IMG, and userdata. img in the out/target/product/generic/directory of the source code directory.
The GCC and G ++ versions of ubuntu11.10 are 4.6. Some errors may occur when Android is compiled using this version, as shown below:
Some say that JDK installation is incorrect. then install JDK again:
1. Download JDK. Http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u30-download-1377139.html, select the jdk-6u30-linux-i586.bin under Linux x86, so that the direct use of thunder download, fast, put on the local machine.
Second, transfer the file to the Ubuntu system. The specific transfer method adopts the Network Neighbor method. For more information, see my other blog: http://www.cnblogs.com/breakmind/archive/2012/01/31/2332522.html.
Third: Open the terminal of ubuntu 11.10. It is difficult to click and view the terminal of ubuntu 11.10. I know there are two methods to enable the terminal of ubuntu 11.10. 1. Shortcut Key: Ctrl + ATL + T. The three keys can be used together to open the terminal. 2. Click the Ubuntu icon (or Microsoft key) in the upper left corner and enter terminal. The terminal is displayed.
4. Execute the command line to implement the entire installation process. (Note that Ubuntu 11.10 has its own openjdk, which is a problem during the entire installation process)
First, copy the JDK to the specified directory, and decompress the copied file to the specified directory. The command line is as follows:
$ Sudo CP jdk-6u30-linux-i586.bin/usr/lib/JVM
$ CD/usr/lib/JVM
$ Sudo./jdk-6u30-linux-i586.bin
$ Sudo MV jdk1.6.0 _ 30/java-1.6.0_30-sun/
$ Sudo ln-s java-1.6.0_30-sun Java-6-sun
$ Sudo RM jdk-6u30-linux-i586.bin.
Set the environment variables, including path, classpath, and java_home. Note the bin directory added at the end of path:
$ Sudo VI/etc/environment
Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/u
Sr/lib/JVM/Java-6-sun/bin"
Classpath = "/usr/lib/JVM/Java-6-sun/lib"
Java_home = "/usr/lib/JVM/Java-6-Sun"
Then we want to tell the system that we are using sun's JDK, instead of openjdk:
$ Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/JVM/Java-6-sun/bin/Java 300
$ Sudo Update-alternatives -- install/usr/bin/javacjavac/usr/lib/JVM/Java-6-sun/bin/javac 300
$ Sudo Update-alternatives -- config Java
The screen is displayed as follows:
Select the path priority status
------------------------------------------------------------
0/usr/lib/JVM/java-6-openjdk/JRE/bin/Java 1061 automatic mode
1/usr/lib/JVM/java-6-openjdk/JRE/bin/Java 1061 manual mode
* 2/usr/lib/JVM/Java-6-sun/bin/Java 300 manual mode
To maintain the current value
Press ENTER or enter the selected number: we enter the value: 2 and press Enter.
As shown above, you have set the Java to be used. Finally, let's verify:
$ Java-version
Java version "1.6.0 _ 27"
Java (TM) se Runtime Environment (build 1.6.0 _ 27-b07)
Java hotspot (TM) server VM (build phases 2-b06, mixed mode)/*
Haili @ haili-desktop :~ $ Sudo gedit ~ /. Bashrc
Append at the end of the file:
Export java_home =/usr/bin/JDK
Export jre_home = java_home/JRE
Export classpath = $ java_home/lib: $ jre_home/lib: $ classpath
Export Path = $ java_home/bin: $ jre_home/bin: $ path
Make the change take effect. Save the file and run
Haili @ haili-desktop :~ $ Source ~ /. Bashrc
Some say this can be solved, but for me it seems that there is only one result, that is, failure. It seems that every step, even a very small step, is so difficult and full of thorns. However, since there is no shortcut to this path, let's keep moving forward, even if it's just a storm. It is certain that the process and the ups and downs can only be realized by yourself.
*/
Reinstall jdk1.6 and now you can make it. The original problem is: After performing the following steps during installation:
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
There is a prompt that the source cannot be read. You need to use "apt-Get Update" to update the source to solve the problem. In this case, execute:
$ apt-get update
Pay attention to this, and re-Execute:
$ sudo apt-get update
Before execution:
$ sudo apt-get install sun-java6-jdk
Otherwise, the above difficult and strange problems may occur. The following describes how to install JDK:
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ Sudo apt-Get update
$ Apt-Get update // this step is required by me
$ Sudo apt-Get update // This step must also be executed. Otherwise, make will always fail. This problem makes the younger brother overhead the whole day.
$ Sudo apt-Get install sun-java6-jdk
Here is what ramdisk. IMG, system. IMG, and userdata. IMG are generated after make, and we look forward to it for a long time. In fact, I don't know how long it took to compile it. I heard it was quite long, But I directly compiled it before work, not a computer. It was all compiled the next day, it usually takes two to three hours for my computer to be configured.
Because of the version, you can consider using a lower version, such as 4.4.
Solution:
The best way to install GCC 4.4 in Ubuntu 32bit system is to use only the following two commands without other commands. Otherwise, errors may occur during compilation:
1 $ sudo apt-Get install gcc-4.4
2 $ sudo apt-Get install g ++-4.4
After installation, go to the/usr/bin directory.
$ LS-l GCC * displays the following results:
Find that GCC is linked to the gcc-4.6 and you need to link it to the gcc-4.4 as follows:
1 $ sudo mv gcc. Bak
2 $ sudo ln-s gcc-4.4 gcc
Similarly, make the same changes to G ++:
1 $ LS-l g ++ *
You need to change the G ++ link to G ++-4.4:
1 $ sudo MV g ++. Bak
2 $ sudo ln-s g ++-4.4g ++
Check the GCC and G ++ versions:
Gcc-V
G ++-V
GCC version 4.4.6 is displayed, indicating that GCC 4.4 is successfully installed.
2. Compile the android Kernel
1. Set Environment Variables
Export Path = $ path:/Android/source/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
Export arch = arm // note = There is no space behind it, and the export cannot be written as an export. Otherwise, a prompt indicating that the command cannot be found is displayed.
Source ~ /. Hashrc
// Make the modification take effect
2. Set cross Parameters
Put this line in the makefile under the kernel/goldfish directory:
Cross_compile? =
To:
Cross_compile? = Arm-Eabi-
In addition, ldflags_build_id = $(patsubst-W1 $ (comma) %, %, $ (call LD-option,-W1 $ (comma)-Build-ID ,), changed:
Ldflags_build_id =
Some netizens say they can also set it in the following ways:
- $ Export arch = arm
- $ Export subarch = arm
- $ Export cross_compile = arm-Eabi-
- $ Source build/envsetup. Sh // This command is missing and may cause compilation failure
- $ Lunch full-Eng // if this command is missing, the module may fail to be started. The system reports that AVD cannot be found and asks you to create an AVD.
Note that you must perform the following two steps:
Export Path = $ path:/Android/source/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
Export arch = arm // note = There is no space behind it, and the export cannot be written as an export. Otherwise, a prompt indicating that the command cannot be found is displayed.
Otherwise, the following message is displayed:
At that time, it took a lot of detours and took a lot of time. At first, I thought it was a problem with the makefile settings above.
You can start the configuration operation here:
$ Make clean
$ Make goldfish_armv7_defconfig // the configuration file make goldfish_defconfig is unavailable. Otherwise, unexpected results may occur in the subsequent steps.
$ Make
Make goldfish_armv7_defconfig and get the following:
The compilation is completed successfully here. The zimage file generated under the arch/ARM/boot directory is displayed. Ls ARCH/ARM/boot
3. The following steps are not used to compile the SDK.
You do not know whether the compiled image is available. To test and use the SDK for development, you need to compile the SDK. Of course, you can also download the SDK from the official website. Because the SDK is not automatically compiled when the android source code and kernel are compiled, You need to manually execute the SDK In the android source code directory:
$ Make product-SDK
Note:
To avoid invalid SDK compilation during environment building, it is best not to use make SDK for the first time instead of the above make product-SDK. There are also android-sdk_eng.xxx_linux-x86.zip and linux-x86 generated under the directory/out/host/android-sdk_eng.xxx_linux-x86/sdkafter compilation. Back up the SDK, because the subsequent module compilation may clear the files under the SDK directory.
4. Compile a separate module
Android allows independent compilation of applications, but it is necessary to regenerate system. IMG. Now, in order to save time, I do not compile a separate module.
5. Compile ADT
The main purpose of ADT compilation is to use eclipse to develop applications. Of course, if you do not want to compile your own files, you can download and install them from the official website or simply update them online.
5.1 configure the environment
To compile ADT, you must first ensure that eclipse is installed in the system. If the installation is not performed, the ADT will be downloaded and installed during compilation. Note that this requires the superuser permission. Otherwise, the installation cannot be performed or compiled. I directly compile the ADT and then let it download and install eclipse on its own. Run:
$ SDK/Eclipse/scripts/build_server.sh/Android/source/ADT (here is the directory where your source code is stored, which should be written according to your own situation)
But it won't be downloaded by itself during compilation. The following prompt is displayed:
It seems that you have to download and install it on the official website. From the prompts, we can download the required information from this website:
Http://download.eclipse.org/technology/epp/downloads/release/galileo/SR2/eclipse-rcp-galileo-SR2-linux-gtk.tar.gz
I download from here: http://www.bergfiles.com/ I /bf4a1420f0h32i0
Eclipse-rcp-galileo-SR2-linux-gtk.tar.gz
You can download the eclipse-rcp-galileo-sr2-linux-gtk.tar.gz file through thunder.
If you want to download from the former, click the following Blue section to download from Thunder:
After downloading, you can see from the prompt:
Downloading and installing eclipse in/buildbot/eclipse-android/3.5.2
Install eclipse in the/buildbot/eclipse-android/3.5.2 directory.
Gedit ~ /. Bashrc:
Export
Eclipse_home = $ path:/opt/boardcon/Android/source_4.0.1/ADT
$ SDK/Eclipse/scripts/build_server.sh/Android/source/ADT
The ADT compilation is complete.