Android source code download and compilation - 2019

Keywords: Android git Ubuntu curl

Android source code download and compilation - 2019 (based on Ubuntu 18.10, applicable to domestic environment)

Download repo tool

If you do not download the repo script tool, please go to Tsinghua mirror to download it

curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo

Then set the update source:

export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'

Download Android

Because Android's source code is getting larger and larger, the probability of repo sync failure is also getting higher and higher.
Therefore, instead of using repo sync, we can download the pre download package:

wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar download initialization package
tar xf aosp-latest.tar
cd AOSP   # Extracted AOSP project directory
repo sync # The complete directory can be obtained by normal synchronization once

Download vendor code

For example, we use the code of hikey960:

wget https://dl.google.com/dl/android/aosp/hisilicon-hikey960-OPR-3c243263.tgz
tar xf  hisilicon-hikey960-OPR-3c243263.tgz

After decompression, extract-hisilicon-hikey960.sh will be generated. Run this file:

./extract-hisilicon-hikey960.sh

Accept the protocol input I ACCEPT, and then you can unzip it successfully.
The following files and directories will be extracted:

vendor/
vendor/linaro/
vendor/linaro/hikey960/
vendor/linaro/hikey960/hisilicon/
vendor/linaro/hikey960/hisilicon/device-partial.mk
vendor/linaro/hikey960/hisilicon/BoardConfigPartial.mk
vendor/linaro/hikey960/hisilicon/proprietary/
vendor/linaro/hikey960/hisilicon/proprietary/libOMX.hisi.vdec.core.so
vendor/linaro/hikey960/hisilicon/proprietary/libc_secshared.so
vendor/linaro/hikey960/hisilicon/proprietary/libhilog.so
vendor/linaro/hikey960/hisilicon/proprietary/libOMX_Core.so
vendor/linaro/hikey960/hisilicon/proprietary/lib64/
vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX.hisi.vdec.core.so
vendor/linaro/hikey960/hisilicon/proprietary/lib64/libc_secshared.so
vendor/linaro/hikey960/hisilicon/proprietary/lib64/libhilog.so
vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX_Core.so
vendor/linaro/hikey960/hisilicon/proprietary/lib64/libstagefrighthw.so
vendor/linaro/hikey960/hisilicon/proprietary/lib64/libhiion.so
vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX.hisi.video.decoder.so
vendor/linaro/hikey960/hisilicon/proprietary/libstagefrighthw.so
vendor/linaro/hikey960/hisilicon/proprietary/libhiion.so
vendor/linaro/hikey960/hisilicon/proprietary/libOMX.hisi.video.decoder.so
vendor/linaro/hikey960/device-vendor.mk
vendor/linaro/hikey960/BoardConfigVendor.mk

Configure compilation environment

Other development environments are basically matched by everyone, so we don't need to talk about it.
Note on Ubuntu 18.10 that ncurses is installed with version 6 by default, while the Android version in March 2019 still requires ncurses 5
Example:

sudo apt install libncurses5-dev

Compile

We still take the hikey960 hardware recommended by Android at present (March 2019) as the target, and the compilation commands are as follows:

. ./build/envsetup.sh
lunch hikey960-userdebug
make -j32

be accomplished!

Posted by melkara on Mon, 09 Dec 2019 12:35:11 -0800