As a qualified Android developer, how can not compile Android source code it! Be sure to come up with a compilation on the journey, otherwise your life is not complete! OK, then let's get to the chase!
This compilation environment uses ubuntu16.04lte,android source selection android6.0! The official recommendation to adopt the UBUNTU14 version, mainly I did not care about the system version, and then directly download the installation version 16.04, and then too lazy to change, so I chose this version .... Let's get down to the chase.
First, build Ubuntu environment.
To the Ubuntu website to download the system image, virtual machine can use VMware Fusion, of course, can also use virtual box, and so on, this does not affect. Specific installation tutorials on the Internet, this article is not verbose ...
The system is installed after the configuration of the Java environment, I test, Oracle JDK8 and open JDK9 can not compile, these two pits everyone must pay attention to .... Compile the error when prompted to use open JDK 1.7.x .... Well, then the Java environment is open jdk1.7, this pit everyone do not step on ...
installation command for openjdk1.7:
- $ sudo add-apt-repository Ppa:openjdk-r/ppa
- $ sudo apt-get update
- $ sudo apt-get install OPENJDK-7-JDK
Do not forget the configuration of the environment variable, if java-version can view the current version information, the environment is configured.
Second, download the system source code
The source of the download online a lot is said to use the Git+repo way to download, but many requests have been unable to access the ... The strength of the wall cannot be looked at directly, so I chose to give up. I use the following the great God provided by the Baidu Cloud, linked to the http://blog.csdn.net/ilittleone/article/details/6823441. Download all down about 7 g, after the download needs to merge resource files, a total of 10 resource files, which have a hash.txt is used to verify the MD5 information, you can choose to ignore. Put the downloaded 10 files in the Unified folder, and then enter this folder on the command line, execute the command cat android6_r1_*>android6.tgz
After successful execution you will find that the current folder has generated Android6.tgz compressed package, decompression can be android6.0 source. OK, let's go into the source code compile link
Third, compile the source of the dependency configuration
The dependency packages required by the UBUNTU12/14/16 are different, and the dependent packages are not successful if the versions do not correspond.
The command is as follows:
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 \
Libgl1-mesa-dev Libxml2-utils Xsltproc Unzip M4
Four, start compiling
Enter the source directory in the command line and execute the following command:
$ source Build/envsetup.sh
$ Lunch Aosp_arm-eng
$ MAKE-J8 (here the number is based on the system configuration, such as 2-Core 2 threads can choose J4, the higher the number of compile faster, the premise of your computer hardware to support ...) )
Then went into the long source code compiled ... Because I encountered a lot of holes in the compilation process, so the whole day is compiling ... It was about 11 o ' sleep before I went to bed. I chose the last attempt ... Then went to bed, woke up to find finally compiled successfully, a line of hope Green hints are as follows:
# # # makecompleted successfully (05:08:19 (HH:MM:SS)) # # #
V. Errors encountered during the compilation process. It must be seen here!
1 Make:***[out/host/linux-x86/obj/lib/libart.so]error 1, such as:
Workaround:
Before compiling, it is recommended to modify this file in the source file: art/build/android.common_build.mk content
Art_host_clang: = False
Ifneq ($ (Without_host_clang), true)
# By default, the host builds use clang for better warnings.
Art_host_clang: = True
endif
Revision changed to
Art_host_clang: = False
Ifeq ($ (Without_host_clang), false)
# By default, the host builds use clang for better warnings.
Art_host_clang: = True
endif
2make: * * * [Out/target/common/docs/api-stubs-timestamp] Error 45
Workaround:
Make clean
Make Update-api
Make
3 after the compilation is completed directly emulator can run the system that has just been compiled successfully, but after we exit the current command line, and then back in use this command will not find this command error
Workaround:
Enter the source directory
SOURCE build/envsetup.sh
Lunchaosp_arm-eng
Then we can execute the emulator.
Vi. Summary
The compilation of the overall is still smooth, a day of time to take care of ... Mainly I this speed, download system image and Andorid source code are two or three m per second ... The purpose of writing this article is to record the experience of this time, but also want to be able to study the system compiled by the people a little help!
The following is the compilation of reference articles, thank you to the experience of the great God!
http://blog.csdn.net/u010856630/article/details/51678745http://blog.csdn.net/chouretang/article/details/ 43769839http://blog.csdn.net/ddk3001/article/details/51454055