You are here

Build Android OS

Initializing a Build Environment, Downloading the Source:

1. http://source.android.com/source/downloading.html

2. 在Ubuntu上下载、编译和安装Android最新源代码
http://blog.csdn.net/luoshengyang/article/details/6559955

3. Ubuntu13.04环境下载、编译Android源代码
http://blog.csdn.net/banketree/article/details/9089827

4. http://docs.omnirom.org/Setting_Up_A_Compile_Environment

5. http://askubuntu.com/questions/281425/how-can-i-remove-my-current-jdk-an...

6. https://www.digitalocean.com/community/tutorials/how-to-install-java-on-...

Building the System:

1. http://source.android.com/source/building-running.html

-------------------------------------------------------------------------------
install Ubuntu 14.04.01 in VMPlaer

1.
$ sudo apt-get update && sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jre openjdk-6-jdk pngcrush schedtool libxml2 libxml2-utils xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib

$ sudo apt-get install bison g++-multilib git gperf libxml2-utils

The master branch of Android in the Android Open Source Project (AOSP) requires Java 7. On Ubuntu, use OpenJDK.(I have tested, OpenJDK does not work)

So i install oracle java 6 and 7:

$ sudo apt-get install oracle-java6-installer

$ sudo apt-get install oracle-java7-installer

To switch Java version
$ javac -version
If it is 1.6, you MUST change it to 1.6 (Java 1.7 isn't supported and you will get build errors)
$ sudo update-java-alternatives -s java-1.7.0-openjdk-amd64

------------------------------------------
In Ubuntu you don't have to uninstall one JDK to use another. You can have multiple Java versions installed and switch between them as you like.

Chose another Java loader:
$ sudo update-alternatives --config java
Chose another compiler (this is what you need):
$ sudo update-alternatives --config javac
Chose Java Web Start:
$ sudo update-alternatives --config javaws
------------------------------------------

To develop older versions of Android, download and install the corresponding version of the Java JDK:
Java 6: for Gingerbread through KitKat
Java 5: for Cupcake through Froyo

3. create ~/android-bin to save repo, and add it to PATH variable
$ cd ~
$ mkdir android-bin
$ export PATH=$PATH:~/android-bin //or add it to ~/.bashrc
$ echo $PATH //check PATH

4.
git config --global user.email "you@example.com"
git config --global user.name "Your Name"

5. download repo script and change it rewrite attribute
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/android-bin/repo

$ chmod a+x ~/android-bin/repo

6 create folder to store android source
$ mkdir myandroid
$ chmod +x myandroid
$ cd myandroid

7 initialize repo working environment,get branch
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.4_r2

8 Downloading the Android Source Tree
$ repo sync

if downloading is corrupted, just run repo sync again.

9 build
$ cd ~/myandroid
$ make

------------------------------------------
I got such error.
You use OpenJDK but only Sun/Oracle JDK is supported

So i install oracle java 6 and 7:

$ sudo apt-get install oracle-java6-installer

$ sudo apt-get install oracle-java7-installer
------------------------------------------
will create 3 folders: root, system, data and
system.img, userdata.img, ramdisk.img (for emulator) 3images.
which located in myandroid /out/target/product/generic

Ref:
repo 的一些用法和理解
http://blog.csdn.net/yasin_lee/article/details/5975068

Blog: