Ubuntu 16.04 LTS successfully compiled Android 6.0 source tutorial

Source: Internet
Author: User
Tags gnupg


1 Preface


After 3 days of fighting, finally in Ubuntu 16.04 on the Android 6.0 source code compiled, various configurations, all kinds of error, a variety of crawl pits, features this blog record crawl pit experience. First, the emulator runs successfully after compiling on Ubuntu,





2 Compiling the Environment
    • Ubuntukylin 16.04 LTS
    • Android 6.0_R1
    • Open JDK 7
3 Preparatory work


(1) Download Android 6.0 source code.


Androdi 6.0 Source: HTTP://PAN.BAIDU.COM/S/1O6N86A2


Thanks to the following blogger upload the source code, I also downloaded from his blog source code:


http://blog.csdn.net/ilittleone/article/details/6823441


Download the source code please download under Windows, Thunderbolt does not explain.
Note: The source of the storage path can not be Chinese, otherwise compiled into the system built-in APK will be error can not parse Class.dex file



(2) Unzip the source code and merge the files.
When the download is complete, use the following command to merge:


cat Android6_r1_*>Android6_r1.tgz


After merging, use the following command to verify the hash:


md5sum Android6_r1.tgz


A hash string is generated at this time,






Compare your downloaded files inside the hash.txt, if consistent then continue, inconsistent then file corruption, re-download.



(3) Unzip the source code.


TAR-ZXVF android6_r1.tgz


Decompression of the source code is a lengthy process, after decompression will be in the current directory to generate a mydroid folder. If you find that the path of the source code has Chinese, need to move the source code, please copy the compressed package, and then use the command decompression, and do not directly copy the extracted folder .



(4) Installing Ubuntu 16.04
Compiling Android source code is best to install Linux directly, do not use virtual machine, compiling the source code is a long process, virtual confidential more than 10 hours, Bo Master directly on the computer installed Ubuntu, compiling only 3 hours. Physical machines can avoid many problems with virtual machines, such as insufficient disk space, insufficient memory, and so on. More importantly, compiling the source code is a continuous crawl of the process, the physical machine can quickly encounter errors, and then solve the problem, continue to compile, again encountered errors, and the virtual machine this cycle will be very long, thus wasting a lot of time. Physical machine decompression is much faster than virtual machines. Ubuntu is well-compatible with Windows, you can install Ubuntu directly as a Windows program, or it can be installed separately, and if you install it separately, be sure to assign at least 120G space to the/home partition because the compiled Android system is really big.
It is highly recommended to download an Ubuntu image and then burn it to a USB flash drive using a floppy drive to install Ubuntu onto the physical machine.



(5) Ubuntu installation Tutorial refer to the following link, Ubuntu 16.04 installation method is the same:


Http://jingyan.baidu.com/article/59703552e0a6e18fc007409f.html


(6) Re-declared: Reprint please indicate from the "Indus at that time Rain" blog: http://blog.csdn.net/fuchaosz/article/details/51487585


4 Installation Dependencies
sudo apt-get Install-y git Flex bison gperf Build-essential libncurses5-dev:i386 sudo apt-get Install libx11-dev:i386 Libreadline6-dev:i386 LIBGL1-mesa-dev g++-multilib sudo apt-get Install Tofrodos python-markdown LIBXML2-utils Xsltproc zlib1g-dev:i386 sudo apt-get Install dpkg-dev LIBSDL1.2-dev libesd0-devsudo Apt-get Install git-core GnuPG Flex Bison gperf Build-essential sudo apt-get install Zip curl Zlib1g-dev gcc-multilib g++-multilib sudo apt< Span class= "Hljs-attribute" >-get install Libc6-dev-i386 sudo apt-get install Lib32ncurses5-dev X11proto-core-dev libx11-dev sudo apt< Span class= "Hljs-attribute" >-get install Lib32z-dev ccachesudo apt-get install Libgl1-mesa-dev libxml2< Span class= "Hljs-attribute" >-utils Xsltproc unzip M4         


Ubuntu 16.04 Please be sure to use the above dependencies , Ubuntu 16.04 needs to rely on and Ubuntu 14.04 need to rely on the different, bloggers follow Ubuntu 14.04 dependent results fell into the pit, see the following compilation process records.


5 Installing the Open JDK7


Android source compilation from Android 6.0 requires installation of OPENJDK, cannot use Oracle JDK, and Android 6 can only use OpenJDK7, such as:






Since Ubuntu 16.04 does not have a OpenJDK7 source, installing OpenJDK7 on 16.04 requires executing the following command:


sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get updatesudo apt-get install openjdk-7-jdk Configure OPENJDK. Open/etc/profile File:
sudo gedit /etc/profile


Append the following code at the end:


export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH





Modifying the/etc/profile file requires a reboot to take effect, but the following command can be used in the current bash environment without restarting:


source /etc/profile


Check that the OPENJDK configuration is correct:


java -version


The configuration is correct, such as:





6 Modify the source code


To modify themydroid/art/build/Android.common_build.mkfile, navigate to line 75 and put the following code:


ifneq ($(WITHOUT_HOST_CLANG),true)


Switch


ifeq ($(WITHOUT_HOST_CLANG),false)


If you do not modify here, you will encounter a tricky compilation error, the purpose of the modification is to clang this compilation option to turn off, see the following compilation record, Baidu Sogou are no solution, This error will only be encountered on the Ubuntu16.04, Ubuntu14.04 does not exist this problem, to solve this compilation error took a day, fortunately, I am good English, in the crooked Fruit of the forum to see a few posts, finally fix. Here, by the way, tips:
Encountered a compilation error, please copy the error message, and then use Sogou Search English page, do not use Baidu that slag


7 Start compiling


(1) Added at the end of the. bashrc file: Export Use_ccache = 1


echo export USE_CCACHE=1 >> ~/.bashrc


(2) To improve compilation efficiency, set the compiler cache:


prebuilts/misc/linux-x86/ccache/ccache -M 50G


(3) Then import the environment variables and other parameters required to compile the Android source code:


source build/envsetup.sh





(4) Run the lunch command to select the compilation target:


lunch





Option 1:



(5) Start compiling, execute Make-j8, 8 is the number of simultaneous compiled threads, generally Google recommends that the number is twice times the number of CPUs plus 2, such as 4 cores, 10. The blogger uses 8:


-j8


For the number of CPUs, you can use the following command to view:


cat  /proc/cpuinfo


OK, start compiling, Next is constantly error, constantly repair, continue to compile the process, the following record my crawl pit experience


7 Compiling records


I started compiling it with the following article:


Http://www.linuxidc.com/Linux/2016-01/127292p2.htm


If it is plain sailing, I will not need to write this blog, but he used Ubuntu14.04, I use the latest Ubuntu16.04, according to the above blog, encountered many pits, here record the following crawl pit experience:
(1) dependence is different. The dependency options for Ubuntu 14 and 16 are different:



libsdl1.2-devinsteadlibsdl-dev, it will bemingw32removed



(2) JDK configuration error.
First use Oracle JDK8 to report the following error:



Change to Oracle JDK7 report the following error:

Instead of OpenJDK7 to solve the problem.



(3) Tai Hang. The following error is then encountered:



Look at the error carefully:


error: linker command failed with exit code


In fact, this is the system using Clang editor error, Baidu a bit, the solution is generally toart/build/Android.common_build.mkifneq ($(WITHOUT_HOST_CLANG),true)changeifeq ($(WITHOUT_HOST_CLANG),false)the file to
However, the paper came to the end of the light, I know this matter to preach, because, this is not any egg, at least for now no eggs. Do not believe, please look at the following post:


http://ask.csdn.net/questions/253318


I tried, also useless, or did not solve the problem, as if this is the compatibility of the new system problem, Baidu Sogou Day, no progress, and later found the following this post, is also 14.04 compiled Android6.0:


http://blog.csdn.net/lewif/article/details/49762993


Hold on anyway bored to try the idea of the above post in the reliance on a copy (so the end of the dependency is two posts added up the dependency):


sudo apt-get install git -core GnuPG Flex Bison gperf build-essential zip Curl Zlib1g-dev gcc-multilib G++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev CCache Span class= "Hljs-subst" >libgl1-mesa-dev Libxml2-utils Xsltproc unzip M4         


Thenmake clean, come back again, and then go to bed.
Wake up, and then ... you think I'm going to make a big story? Oh, this error is finally made up, but encountered the following error:



To solve this mistake, but also to spend a lot of effort, in the crooked Fruit of the forum to see the following this post:


Http://forum.xda-developers.com/chef-central/android/guide-how-to-setup-ubuntu-16-04-lts-t3363669/page2


Watch this post on the 15 floor, haha, this time to find a solution, and then modify theart / build/Android.common_build.mkfile


ifneq ($(WITHOUT_HOST_CLANG),true)


Switch


ifeq ($(WITHOUT_HOST_CLANG),false)


Recompile to resolve the issue.



(4) Chinese path, pit.



It is difficult to meet this problem Baidu to, hey, finally to the source of the full English path below, to solve the problem. Note When moving the source code, do not copy the Mydroid folder directly, one hours are not complete, so the correct way is to copy the compressed package, and then unzip again.
Then the compilation was successful.


8 compilation succeeded


After successful compilation, such as:



Into the Mydroid/out/target/product/generic directory, you can see the compiled files:



To start the emulator:


emulator


Wait a moment, you can appear at the beginning of the simulator screen, haha, finish the call.


9 Appendix: Ubuntu 16.04 compilation rom English course


Finally, attached to look at the post, found in the Ubuntu16.04 compiled AOSP, CyanogenMod tutorial, of course, is in English:


http://forum.xda-developers.com/chef-central/android/guide-how-to-setup-ubuntu-16-04-lts-t3363669

10 Summary


Android system source code compilation is constantly and all kinds of error to fight the process, test the ability of programmers to obtain information, encountered error when only a variety of Baidu Sogou, but this is also very exercise ability process, Bo Master in the process of compiling the greatest experience is: English must be better, haha. If you compile successfully, or compile a problem, welcome to leave me a message.


11 reprint Please specify from "Indus Then Rain" blog: http://blog.csdn.net/fuchaosz/article/details/51487585


Ubuntu 16.04 LTS successfully compiled Android 6.0 source code tutorial (GO)


Related Article

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.