Compile the Android6.0 source code on Ubuntu Server14.04 and the android source code on ubuntu

Source: Internet
Author: User

Compile the Android6.0 source code on Ubuntu Server14.04 and the android source code on ubuntu

I have compiled the source code for Android4.4 before, but now Android has reached version 7.0, so I can't help but lament that Google's pace is really hard to keep up with, and this weekend is quite abundant, so in the past 24 hours, I spent nine hours compiling the source code of Android6.0. However, it was very late after yesterday's compilation, and I didn't have time to record the compilation steps, today, I recorded the steps for compiling the Android6.0 source code on Ubuntu Server14.04. Let's get started!

Step 1:

Install Ubuntu. We can either install Ubuntu through a virtual machine or directly on a computer. For a better Linux operating experience, we recommend that you install Ubuntu directly on your computer, I have installed the win10 and cmdut Server14.04 dual systems on my computer. It is very convenient to switch the system at any time as needed. There are many tutorials on how to build a dual-system. I will not describe them here, but I want to explain that when installing Ununtu, the disk space allocated to Ubuntu must be as large as possible, at least 60 GB, I allocated 105 GB, and more than 50 GB after compilation, that is, nearly 50 GB of space is used, therefore, when installing Ubuntu, you must allocate a larger disk space. Otherwise, compilation may be interrupted due to insufficient space.

Step 2:

After setting up the Ubuntu system, we need to download the Android6.0 source code. Many articles on the Internet have introduced how to download the source code through repo, however, the download speed may not be ideal. I directly download the Android6.0 source code that someone else has uploaded to Baidu cloud: http://pan.baidu.com/s/1o6n86a2?path=255.252f.

Because the source code of Android6.0 occupies a large amount of space, the Uploader divides the Android source code into many files. After all the files are downloaded, we can use commands to merge these separated files into one file.

Step 3:

If we download the source code on Windows, the first thing we need to do after we open Ubuntu is to copy the Android source code in Windows to the Ubuntu system, I directly copy and paste the source code to the Home Directory of Ubuntu, and copy the directory structure Home/android6_r1/to separate source code files.

Step 4:

Merge these separated source code files. Press ctrl + alt + T on the keyboard to open the console, run the cd command to enter the Home/android6_r1/directory, and then run the command: cat Android6_r1 _ *> M. tgz, it will not be long before a new file will be generated under the Home/android6_r1/directory -- M. tgz, M. tgz is the compressed file after merging.

Step 5:

Extract the compressed file generated in step 4. In the Home/android6_r1/directory, run tar zxvf M. tgz on the console to decompress the package. The decompression process may take about 20 minutes. Please wait. After decompression, A mydroid folder is generated in Home/android6_r1/, which is the root folder of the Android source code, including abi, devices, hardware, packages, sdk, and art folders and files.

Step 6:

Install the software required to compile the source code. In the console, we use the cd .. command to return to the root directory of the Unbuntu user, and then execute the following commands in sequence:

Sudo apt-get update

Sudo apt-get install openjdk-7-jdk

Sudo update-alternatives -- config java

Sudo update-alternatives -- config javac

Each of the preceding commands must be executed separately to obtain jdk 1.7 and set environment variables. After Ubuntu is installed, a jdk may be provided. However, if you use the built-in jdk to compile the Android source code, it is likely that the jdk version does not meet the requirements, so we need to download jdk 1.7 again, and I don't have any problems with openjdk-7-jdk compilation.

Next, run the following command 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 unzip tproc zlib1g-dev: i386

Sudo ln-s/usr/lib/i386-linux-gnu/mesa/libGL. so.1/usr/lib/i386-linux-gnu/libGL. so

The above commands are mainly used to install various software used for compiling the source code. If these software is not installed, the compilation process prompts that the necessary software is missing and the compilation cannot be continued. Therefore, install the software before compiling the source code.

Step 7:

Start compilation. Run the cd command on the console to go to the Home/android6_r1/mydroid/directory, and run the command: source build/envsetup. sh to import environment variables and other parameters required for compiling Android source code.

Step 8:

Run the command: lunch in the console. After running the command, we will be prompted to select the compilation target. Here, the default target I selected is aosp_arm_eng.

Step 9:

Run make-j8 on the console to start compilation. Note that the number 8 in the make-j8 command is related to the number of CPU cores and threads on our computer. Generally, the number cannot exceed twice the number of CPU threads, for example, my computer's processor is i5 6200U, which is a dual-core quad-thread. Therefore, when compiling the Android source code, I can set the maximum number of worker threads to 4x2 = 8. When executing the make command, we should set a reasonable working thread value based on our CPU parameters.

After the above steps are completed, it is a long wait. I started to compile at noon until the compilation was completed at. The entire compilation process took more than nine hours, fortunately, I was lucky. There was no error in the compilation process, but I accidentally interrupted it once. However, the Android source code can continue to be compiled at the last interrupted location, the compiled part will not be compiled repeatedly, so it does not have a big impact on me. Comrades, what I want to say is that the compilation process must be patient!

After the source code is compiled, if the following message is displayed, Congratulations, you are successful !!!

  

At this point, you can directly execute the command: emulator. After the command is executed, the android Simulator Interface will appear,

  

  

  

OK. Now the compilation of the Android6.0 source code is complete. Next, we can read and modify the source code as we like and customize our own Android system!

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.