Obtain and compile the Android4.0 source code in Ubuntu (1)

Source: Internet
Author: User
Tags gnupg
Document directory
  • Step 1: Initialize the compiling environment
  • Step 2: Create a Linux compiling environment
  • Step 3: Prepare to download the Android source code
  • Step 4: start downloading the Androd source file

After several months of Android Application Development, it is barely an Android developer. The Android version is open-source. You can download the source code and compile it yourself to see what it is, out of curiosity, and the future career development, I started the endless Android research process...

This serialization blog is used to record the entire process from downloading the source code to compiling. Baidu and Google have made numerous materials and encountered many problems to sum up. I hope it will be helpful to later users, that's a summary.

Next, we will first develop and obtain the latest Android source code. The latest version is 4.0.

To get the source code, of course, you have to look at the official documentation to say how http://source.android.com/source/initializing.html

 

Step 1: Initialize the compiling environment

To build the Android source files, you will need to use Linux or Mac OS. Building under Windows is not currently supported

This generally refers to compiling Android source code files. You need to use Linux or Mac OS. Compiling in Windows is not currently supported. Therefore, you need to install a Linux File, I am currently using Ubuntu installed on a virtual machine. Of course, others can also be used.

Note: The source download is approximately 6 GB in size. You will need 25 GB free to complete a single build, and up to 80 GB (or more) for a full set of builds.

This statement indicates that there is a limit on the space capacity. I am still downloading it. It is said that there will be about 6 GB after the download is complete. It is recommended that you divide the space into much space.

Step 2: Create a Linux compiling environment

After Ubuntu is installed on a virtual machine (we recommend that you disconnect the network when installing Ubuntu, or skip the skip when downloading something from the network. This will make the installation faster, I used the latest ubuntu11.10). Next:

Install JDK

Generally, after ubuntu is installed, it comes with openJDK. here we need to use Sun's JDK, but Sun JDK is no longer in the ubuntu software source. In order to download it, you need to add a software source address. Do you want to use JDK 5 or JDK 6? According to official explanations, JDK 6 is suitable for compiling Gingerbread (ginger pie) or an updated version, that is, Version 2.3 or later. For Version 2.3 or earlier, JDK 5 is recommended, here we compile 4.0, of course JDK6 is used.

Run the following three statements on the terminal:

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

As prompted, install it step by step. Remember that a prompt box will be displayed on the terminal during installation, similar to the license agreement. There is a confirmation below, but it cannot be clicked, press the Tab key and select it. If you confirm it, the JDK will be installed. You can test it on the terminal and run

$java -version

If the corresponding version prompt is displayed, the installation is successful.

Next, if it is a 32-bit system, run

$ 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 libreadline6-dev libgl1-mesa-dev tofrodos python-markdown \
libxml2-utils xsltproc

If it is 64-bit, run

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc

64-bit is officially recommended. I didn't see it at the time, and it won't be too difficult to use 32-bit. After executing this step, Git and Python have been installed, except JDK, both are required. Now we have to prepare to download the source code...

Step 3: Prepare to download the Android source code

Next, you need to install, initialize, and configure the Repo tool.

  • Install Repo

First, make sure there is a bin directory under your home directory. If not, run the following command:

$ mkdir ~/bin
$ PATH=~/bin:$PATH

Then download the Repo script and make sure it can be executed.

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
  • Initialize the Repo Client

First, create an empty directory to save the working file.

$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY

Then initialize Repo

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
Step 4: start downloading the Androd source file
$ repo sync

This is a long process. Wait. If you find that the screen is stuck, there is no movement, no traffic is displayed, or you cannot feel it is being downloaded, it is similar

It is recommended that you interrupt (press ctrl + z) and re-Execute step 3 (repo sync). Then you will see the download information. When you execute repo sync for the first time, there may be an error message, but you cannot remember it clearly. Baidu will also come out and re-run the repo sync command...

I am currently downloading it. Please wait.

 

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.