Ubuntu 16.04 compiled Android 7.1.2

Source: Internet
Author: User

Toss for a long time, finally took care of the environment. Record it.

Preparatory work:

1. First download the official image of Ubuntu16.04 on the Ubuntu website. Official website (this search for a long time, here can directly download the ISO image): https://launchpad.net/ubuntu/+cdmirrors

2. It is recommended to install directly on your own hard drive (recommended dual system), do not engage in virtual machines, unless you have a large enough SSD. I tried before on the virtual machine, the performance of the computer completely do not come out, and then made a double system, found that everything is so comfortable.

3. Android Source code download method: Https://lug.ustc.edu.cn/wiki/mirrors/help/aosp

The following assumes that the Ubuntu system has been prepared and downloaded the source of the Android 7.1.2 (other versions are OK).

Environment configuration:

1. Install the basic dependency software:

Note that I am using Ubuntu 16.04, the following dependent software is based on the Ubuntu16.04, if you do not use Ubuntu16.04, then according to your actual situation, or you may have an error.

sudoApt-getInstall-y git Flex bison gperf build-essential libncurses5-dev:i386sudoApt-getInstalllibx11-dev:i386 libreadline6-dev:i386 Libgl1-mesa-dev g++-MultilibsudoApt-getInstallTofrodos Python-markdown libxml2-utils Xsltproc zlib1g-dev:i386sudoApt-getInstallDpkg-dev LIBSDL1.2-dev libesd0-DevsudoApt-getInstallGit-core GnuPG Flex Bison gperf build-EssentialsudoApt-getInstall ZipCurl Zlib1g-devGCC-multilib g++-MultilibsudoApt-getInstalllibc6-dev-i386sudoApt-getInstallLib32ncurses5-dev X11proto-core-dev libx11-DevsudoApt-getInstalllib32z-Dev CCachesudoApt-getInstallLibgl1-mesa-dev libxml2-utils XsltprocUnzipM4

2. Depending on the version of the Android code that you downloaded, select the JDK version you want to install

The Android version I downloaded is 7.1.2, and the required JDK version is OPENJDK-8-jdk. Ubuntu default comes with the OpenJDK-8-jdk installation source, can be installed directly, using the following command to install:

sudo apt-get updatesudoinstall openjdk-8-jdk

If you are using OpenJDK7, because Ubuntu 16.04 does not have a OpenJDK7 source, add the source first, and then in the installation OpenJDK7, follow the command below:

sudo add-apt-repository ppa:openjdk-r/sudo apt-get updatesudo  Install openjdk-7

After installation, execute the following command to add the Java_home related configuration

sudo gedit/etc/profile

At the end of the open profile file, add the following:

Export java_home=/usr/lib/jvm/java-8-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

Finally, check that the JDK is installed successfully:

Java-version

3. Compile parameter configuration

After the basic environment is ready to complete, the following starts the Android compilation related configuration.

1) Modify the Android_common_build.mk file to find the Without_host_clang,

Ifneq ($ (Without_host_clang),true)

Modified into

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 turn off the clang this compilation option.

2) Modify the. bashrc file

Execute the following command in the terminal and add it at the end of the. bashrc file: Export Use_ccache = 1

echo export use_ccache=1 >> ~/.BASHRC

To improve compilation efficiency, set the compiler cache:

Prebuilts/misc/linux-x86/ccache/ccache-m 50G

3) in order to avoid the "Try increasing heap size with Java option xmx<size>" error when compiling, the jack_server_vm_arguments configuration needs to be modified. Modify the Prebuilts/sdk/tools/jack-admin file to add -xmx4096mafter jack_server_vm_arguments. A total of 2 places, to be modified.

After the modification is complete, remember to restart the Jack server, execute the following two commands, be sure to execute the following command, otherwise the above modification may not take effect:

Kill-server. /prebuilts/sdk/tools/jack-admin Start-server

Formal compilation

Prepared after the work, basically OK, good luck, in the compilation when the basic will not have problems. Execute the following command in order to compile, of course, as the personal computer Configuration, the time required for compiling may be very different, if you feel-j8 too much, you can use make directly, the default is-J4:

SOURCE Build/envsetup. SH Lunch  make-j8

Once the compilation is successful, execute the following command to open the Android emulator and start using your own compiled system.

Emulator

The effect is as follows:

Resources:

1. http://blog.csdn.net/fuchaosz/article/details/51487585/

2. http://blog.csdn.net/csdn_zyp2015/article/details/56277765

Ubuntu 16.04 compiling Android 7.1.2

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.