Compiling Android6.0 source code on Ubuntu Server14.04

Source: Internet
Author: User

Previously compiled Android4.4 source code, but now Android to 7.0 version, can not help let me sigh Google's pace really difficult to keep up, while this week weekend more abundant, so in the past 24 hours, resolutely spent 9 hours compiled a Android6.0 source code, but yesterday after compiling Already very late, did not have time to record compiles the step, today only then slowly to record I in the Ubuntu Server14.04 compiles the Android6.0 source code the step. Well, no more nonsense, let's get started!

Step One:

Install Ubuntu System. We can either install Ubuntu from a virtual machine or install it directly on a PC, and for a better Linux experience, I recommend installing Ubuntu directly on your computer, and I've installed win10 and ubunut on my computer. Server14.04 dual system, the use of the time can be based on their own needs to switch the system at any time, very convenient. about how to build a dual system, there are many tutorials on the web, I do not describe here, but I would like to point out that in the installation of Ununtu, the disk space allocated to Ubuntu must be as large as possible, at least 60G, I allocated 105G, after the completion of the compilation of more than 50 g, That means almost 50G of space, so when installing Ubuntu must allocate a larger disk space, or the compilation will be due to lack of space and interrupted.

Step Two:

After setting up the Ubuntu system, We need to download a copy of Android6.0 's source code, many articles on the Internet have introduced how to download the source code through repo way, but this way download speed may not be ideal, I was directly downloaded by others have been uploaded to the Android6.0 source of Baidu Cloud,:/http pan.baidu.com/s/1o6n86a2#path=%252f.

Because the Android6.0 of the source of space is very large, so the uploader to the Android source is divided into a number of files, after the download is complete, we can use the command to merge these separate files into a file.

Step Three:

If we are downloading the source code on Windows, then when we open Ubuntu, the first thing to do is to copy the Android source in Windows to the Ubuntu system, I directly copy and paste the way the source copy to the Ubuntu home directory, after the copy of the directory structure home/android6_r1/each separate source files.

Step Four:

Merge these separated source files. We press CTRL + ALT + T on the keyboard to open the console, go to the home/android6_r1/directory via the CD command, and then execute the command: Cat android6_r1_* > M.tgz, not long before HOME/ANDROID6_R1 /directory will generate a new file--m.tgz,m.tgz is the compressed file after merging.

Step Five:

Unzip step four to generate the compressed file. Also under the home/android6_r1/directory, we execute the command in the console: Tar zxvf m.tgz, start unpacking. The decompression process takes about 20 minutes, please wait patiently. After the decompression, the home/android6_r1/will generate a mydroid folder, this folder is the root folder of Android source code, there are ABI, devices, hardware, packages, SDK, Folders and files such as art.

Step Six:

Install the software required to compile the source code. In the console we pass the CD. The command returns to the root of the Unbuntu user, and then executes the following command in turn:

sudo apt-get update

sudo apt-get install OPENJDK-7-JDK

sudo update-alternatives--config java

sudo update-alternatives--config javac

Each of the above commands must be executed separately in order to obtain the 1.7 version of the JDK and set the environment variables. We may bring a JDK after we install Ubuntu, but if we compile the Android source with our own JDK it is likely that the JDK version does not conform to the required error, So we need to re-download the 1.7 version of the JDK, I compiled with openjdk-7-jdk without any problems.

Next, continue with the following commands, and each line is executed separately:

sudo apt-get install git gnupg Flex Bison gperf build-essential

sudo apt-get install zip curl Libc6-dev libncurses5-dev:i386 X11proto-core-dev

sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386

sudo apt-get install Libgl1-mesa-dev g++-multilib mingw32 Tofrodos

sudo apt-get install python-markdown libxml2-utils xsltproc zlib1g-dev:i386

sudo ln-s/usr/lib/i386-linux-gnu/mesa/libgl.so.1/usr/lib/i386-linux-gnu/libgl.so

The above command is mainly installed to compile the source code need to use a variety of software, if not installed these software, the process will be prompted to compile the necessary software can not continue to compile, so before formally compiling the source code, you must first install the software.

Step Seven:

Start compiling. Enter the Home/android6_r1/mydroid/directory through the CD command in the console and execute the command: source build/envsetup.sh, import the environment variables and other parameters required to compile the Android source code.

Step Eight:

Execute command in console: Lunch, after running the command, we will be prompted to select the compilation target. Here I choose the default target, namely Aosp_arm_eng.

Step Nine:

Execute command in console: Make-j8, start compiling. Note that the number 8 in the MAKE-J8 command is related to the number of CPU cores and the number of threads in our computer, generally this number can not exceed twice times the number of CPU threads, for example, my computer's processor is i5 6200U, dual core four threads, so when compiling Android source code, The maximum number of worker threads I can set is 4 * 2 = 8. When executing the make command, we should set a reasonable value for the working thread based on our CPU parameters.

After the completion of the above steps, is a very long wait, I start from 12 o'clock Noon to compile, until the end of the night to nine o'clock more compiled, the entire compilation process took nine hours, fortunately, my luck is good, the compilation process did not appear any errors, just midway accidentally interrupted once, But the Android source code can continue to compile the location of the last interruption, the compiled parts will not be compiled repeatedly, so it has not caused me a big impact. Comrades, I want to say is that the process of compiling must be patient yo!

After the completion of the entire source code, if prompted the following information, then congratulations, you is successful!!!

  

At this point, you can directly execute the command: emulator, after execution will appear the Android emulator interface,

  

  

  

OK, at this point Android6.0 source of the compilation is done, next we can read and modify the source content, customize their own mind of the Android system!

Compiling Android6.0 source code on Ubuntu Server14.04

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.