Android source code compilation (ubuntu16.04 64-bit)

image.png

table of Contents##

The first article: android source code compilation (ubuntu16.04 64-bit)
Chapter 2: [Compilation Supplement (About downloading code and insufficient memory)] (https://www.jianshu.com/p/abb82793dc67)

Compilation steps##

**1. Download the source code; ****2. Build the compilation environment; ****3. Compile the source code; **4. Run.

Before compiling, first download and install the repo and gitt tools.

repo and git

Google uses Git for multi-warehouse management of AOSP projects.
In order to facilitate the need, the git statement is encapsulated and a repo is formed.

Create a compilation folder##

$ mkdir source
$ cd source

Note that the disk space where this folder is located must be greater than 100G, and a lot of space is required after compilation.

Initialize the warehouse##

$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest

Tsinghua mirror server used.

Download code##

$ repo sync

The synchronization time is very long. It is recommended to synchronize before going to bed at night. It will take a few hours.

Install JDK

In AOSP Open Source, the main branch is developed and tested using the long-term version of Ubuntu, so it is also recommended that you use Ubuntu to compile. Below we list the different versions of Ubuntu that can compile those android versions:

Android version Minimum version of Ubuntu required for compilation
Android 6.0 to AOSP master Ubuntu 14.04
Android 2.3.x to Android 5.x Ubuntu 12.04
Android 1.5 to Android 2.2.x Ubuntu 10.04

Corresponding sdk version:

Android version Compile required JDK version
AOSP’s Android mainline OpenJDK 8
Android 5.x to android 6.0 OpenJDK 7
Android 2.3.x to Android 4.4.x Oracle JDK 6
Android 1.5 to Android 2.2.x Oracle JDK 5

* Use OpenJDK 8 this time

$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk

Install dependent libraries##

$ sudo apt-get update
$ sudo apt-get install git-core gnupg flex bison gperf build-essential
$ sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386
$ sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache
$ sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4

Start compiling##

Compile target format description#####

The format of the compilation target: BUILD-BUILDTYPE, for example, the BUILD of aosp_arm-eng above is aosp_arm, and the BUILDTYPE is eng.

BUILD refers to the specific name of the combination of specific functions, which means that the compiled image can run in what environment. Among them, aosp (Android Open Source Project) stands for Android open source project; arm means that the system is running on a processor of the arm architecture , arm64 refers to the 64-bit arm architecture; processor, x86 refers to the x86 architecture processor; in addition, there are some words representing specific Nexus devices, the following are commonly used device codes and compilation targets

$ source build/envsetup.sh
$ lunch aosp_arm64-eng
============================================
PLATFORM_VERSION_CODENAME=Q
PLATFORM_VERSION=Q
TARGET_PRODUCT=aosp_arm64
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-131-generic-x86_64-Ubuntu-16.04.5-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=PI
OUT_DIR=out
============================================
$ make -j8

Set the number of threads participating in compilation through the -j parameter to improve compilation speed. For example, here we set 8 threads to compile at the same time.

It should be noted that the more threads participating in the compilation, the better, it is usually determined according to the core of your machine's cup: core*2, which is twice the core of the current cpu.

The result of successful execution:

image.png

I compiled this for four hours. . . .

Run the simulator##

$ source build/envsetup.sh
$ lunch

At lunch, select the target version just set.

$ emulator

operation result:

image.png

I don't know why it is a black screen, but at any rate the compilation is fine. Continue to study! !

Recommended Posts

Android source code compilation (ubuntu16.04 64-bit)
Introduction to Android source code compilation (ubuntu16.04+android P)
Ubuntu 18.04 source code compile and install ffmpeg4.1
Download OpenJDK11 source code in Ubuntu environment
Ubuntu 18.04 install Odoo14 tutorial through source code
Edit OpenJDK11 source code in Ubuntu environment
ubuntu kernel compilation
ubuntu replacement source
Ubuntu update software source
Ubuntu builds Eclipse+JDK+SDK Android
Ubuntu make offline source
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
Ubuntu ssh Android phone
ubuntu 14.04 16.04 18.04 use Alibaba source
Find the kernel source code corresponding to the running Ubuntu version
Android phone running Ubuntu tutorial
Install Android Studio on Ubuntu
Build Ubuntu 12.04 cross compilation server
Centos compile JDK8 source code
ubuntu install chrome browser 64 bit