Android is a milestone in the development of embedded Linux. In recent years, there have been a large number of Embedded Linux applications, and some people have come to unify the world, give confidence and a success model. Android is a successful example of embedded Linux!
The open source code for Android is too helpful for studying all aspects of the embedded field! Drivers, operating systems, virtual machines, build systems, Java language, C/C ++ language, integration of open-source software, and so on can learn too much from Android!
This article describes how to download and compile the android core source code and how to compile and use the ADT and SDK!
0. Introduction
ADT is an Eclipse plug-in for Android. It provides basic tools, including SDK acquisition and configuration. Therefore, developing Android app ADT is a required tool!
The SDK is a software development kit. sdks are released on various platforms for developers to use!
The android Source Code does not include the kernel source code. It needs to be downloaded and compiled separately!
SDK and ADT can be compiled directly from the android source code!
Repo is the encapsulation of git to facilitate the acquisition of the android source code. The source code is maintained by git, so the same is true for obtaining the source code by git.
In addition, all documents on www.android.com are available, and documents on the Internet are also available on the official website!
I. Basic Development Environment
Ubuntu-10.04 can be, install a local source image, and then install the software package to speed up! The subsequent content of this article assumes that the system is a Ubuntu-10.04!
2. Install the system tools required for Android Compilation
Official reference page: http://source.android.com/source/initializing.html
(1) install the Java environment
$ Sudo add-Apt-repository "Deb http://archive.canonical.com/lucid partner" $ sudo apt-Get update $ sudo apt-Get install sun-java6-jdk
Note: Under ubuntu12.04
A. Install JDK 6 for Android
B. http://www.oracle.com/technetwork/java/javase/downloadsdownload jdk6
C. Download JDk-6u37-linux-x64.bin
D. Put it in a suitable directory, such as/home/RDA/work/soft/./to the current directory.
E. Modify ~ /. Add environment variables to bashrcExport java_home =/usr/lib/JVM/Java-7-sun // modify according to the actual path
Export jre_home =$ {java_home}/JRE
Export classpath =. :$ {java_home}/lib :$ {jre_home}/lib
Export path =$ {java_home}/bin: $ path
(2) install required software packages
$ Sudo apt-Get install Git-core GnuPG flex bison gperf build-essential zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev libx11-dev libreadline5-dev libz-dev libgl1-mesa-dev g ++-multilib mingw32 tofrodos Python-markdown libxml2-utils unzip tproc
3. Obtain source code
Official reference page: http://source.android.com/source/downloading.html
Current androidCodeHosted in two places: Https://github.com/android And Https://android.googlesource.com Previously hosted on android.git.kernel.org, but now redirected Https://android.googlesource.com Fortunately, git access is supported.
(0)Sudo apt-Get install Git-core
Curl
(1) create a repo tool Directory, which encapsulates the GIT source code control tool
$ Mkdir ~ /Bin $ Path = ~ /Bin: $ path
(2) Get repo Tool
$ Curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo> ~ /Bin/repo $ chmod A + x ~ /Bin/Repo
(3) initialize the repo Client
$ Mkdir working_directory $ CD working_directory
$ Repo init-u https://android.googlesource.com/platform/manifest-B android-4.0.1_r1
(4) obtain the source code
$ Sudo sysctl-W net. ipv4.tcp _ window_scaling = 0
$ Repo sync-J1
At this time, there may be too many connections and errors may occur, but it doesn't matter. Use repo sync to try it first. If not, use the following method to try again.
(4.0) in case of an error: downloaderror: android.googlesource.com: <urlopen error [errno 110] connection timed out>
This indicates that the server rejects too many links and can apply for authorization. This is a simple ticket:
Reference: http://blog.csdn.net/thl789/article/details/7524232
1. log on to https://android.googlesource.com/new-passwordin the browser and use the gmailaccount number to renew it;
2. Click "Allow access" on the webpage to obtain the following information:
- Machine android.googlesource.com login Git-<username> .gmail.com password <password>
- Machine android-review.googlesource.com login Git-<username> .gmail.com password <password>
Machine <br/> android.googlesource.com login Git-<username> .gmail.com password <br/> <password> <br/> machine android-review.googlesource.com login <br/> Git-<username> .gmail.com password <password>
.
3. append the above information (<username> and <password> with your own real information) ~ /. The End Of The netrc file;
4. Uri changed to https://android.googlesource.com//Platform/manifest ("/a" is added in the middle.
Repeat Step (3) and use
Repo init-u https://android.googlesource.com/a/platform/manifest-B android-4.0.1_r1
And then repo sync.
4. Compile the Android system
1. Compile the entire system
Official reference link: http://source.android.com/source/building.html
Starting ccache will accelerate compilation, but it will also cause problems. We recommend that you do not use it first!
(1) Enable the environment
$ Source build/envsetup. Sh
(2) configuration target
$ Lunch full-Eng
(3) Compile the source code
$ Make-J4
After compilation is successful, you can run the simulator to check the effect. The command is as follows:
Export android_product_out = $ PWD/out/target/product/generic
Export android_swt = $ PWD/out/host/linux-x86/framework
Export Path = $ path: $ PWD/out/host/linux-x86/bin
Emulator to see the effect!
2. Compile the SDK
(1) Enable the environment
$ Source build/envsetup. Sh
(2) configuration target
$ Lunch SDK-Eng
(3) Compile the source code
$ Make SDK-J4
(4) The compilation result is in the out/host/linux-x86/SDK directory is the SDK directory, this directory can be backed up
3. Compile ADT
Export eclipse_home = <xxxxxx> eclipse root directory
SDK/Eclipse/scripts/build_server.sh./ADT/
The aforementioned script can be used to compile ADT, but I have never succeeded! This will depend on the later eclipse, which can be compiled after eclipse is installed!
Back up the SDK before compiling.
4. Compile the kernel
Official reference link: http://source.android.com/source/building-kernels.html
Refer to the above link. It is relatively simple!
5. Create an android Development Environment on Eclipse
Official reference link: http://developer.android.com/sdk/installing.html
(1) Obtain eclipse
Http://www.eclipse.org/downloads/download.php? File =/technology/EPP/downloads/release/indigo/Sr2/eclipse-rcp-indigo-SR2-linux-gtk.tar.gz & url = http://download.actuatechina.com/eclipse/technology/epp/downloads/release/indigo/SR2/eclipse-rcp-indigo-SR2-linux-gtk.tar.gz&mirror_id=385
Decompress the package and use it directly! We recommend that you download the RCP version!
(2) Get ADT
If it is compiled on the front, it is reasonable to say that you do not need to download or install it online. Here is the download method!
Http://dl.google.com/android/ADT-18.0.0.zip this is the latest, download it
(3) install ADT
Install new Softwarein eclipse help, select achive, and select adt-18.0.0.zip to complete the installation.
(4) install the SDK
SDK front has been compiled out, directory is about out/host/linux-x86/SDK/, configure adt sdk directory can be, other do not need to configure!
(5) Create an AVD
AVD is a virtual device. You can create it!
So far, this article describes the Android system compilation, SDK installation, and development environment!
This article is complete!