In some cases, we need to check the android source code or recompile it. Currently, only Android source code can be compiled on Linux or Mac OS, But windows is not supported. so this article introduces how to obtain the android source code on Ubuntu.
The android source code is about 2.1 GB. here we can see its structure and update records.
Git and repo are required to download the android source code. Git is an open-source distributed version control software that is ideal for managing large projects. project files can be stored in multiple git repositories (repositories ), in this way, you can easily create branches and compare versions. Therefore, Android also uses them for source code management. Repo is a git-based tool that allows us to manage git repositories more conveniently.
Next, we need to install these two tools on Ubuntu. Before installation, We need to install some necessary Linux packages: JDK 5.0 (Java 6 does not support @ override incompatibility), Lex, bison, gperf, libsdl-Dev, libesd0-dev, libwxgtk2.6-Dev (optional), build-essential, zip, curl.
Run the following command on Terminal in Ubuntu: $ sudo apt-Get install Git-core GnuPG flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
Here you need to pay attention to the sun-java5-jdk source in ubuntu9.10 after there is no, so the installation of sun-java5-jdk to switch sources. List to install, specific can refer to this blog.
After git (GIT-core above) is installed, install Repo, create the bin directory in the home directory, obtain the repo, and grant it the execution permission:
$ Cd ~
$ Mkdir Bin
$ Curl http://android.git.kernel.org/repo> ~ /Bin/Repo
$ Chmod A + x ~ /Bin/Repo
Add the bin directory to $ path:
$ Export Path = $ home/bin: $ path
Then create the mydroid directory in the home directory to store the android source code.
$ Mkdir mydroid
$ CD mydroid
Finally, download the android source code:
$ Repo init-u git: // android.git.kernel.org/platform/manifest.git
$ Repo sync