Ubuntu 18.04 compiling Android 10.0 system source code

Compiling environment

1. Ubuntu 18.04 system

2. Samsung 500G SSD EVO series

3. Memory 8G, cpu 4 cores, i5


1. Download git

sudo apt-get install git

git can't download the initial problems. The following information is prompted

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.

Solution, implementation

sudo apt-get upgrade
sudo apt-get install git

2. Set up git account

git config --global user.email "xxxxxxx@gmail.com"
git config --global user.name "xxxxx"

3. Download python

sudo apt-get install python

4. Configure PATH environment variable

mkdir ~/bin
echo "PATH=~/bin:\$PATH" >> ~/.bashrc
source ~/.bashrc

5. Install curl library and set permissions

sudo apt-get install curl
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo

Download source code

1. Create working directory

mkdir android10
cd android10

2. Add image source of Tsinghua University

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

3. Initialize the repository and specify to download the android version

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-10.0.0_r10

4. Synchronous source code

repo sync -j8

Just wait slowly. If you have a fast Internet speed, it is possible to download in 2 hours. During the download, it may fail. If it fails, execute repo sync-j8 again. I download it all night.

Compile source code

1. Install openjdk8

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk

If there are multiple java versions in the computer, select openjdk-8 by the following command

sudo update-alternative --config java
sudo update-alternative --config javac

2. Install dependency Library

sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
sudo 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-get install libc6-dev-i386
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo apt-get install lib32z-dev ccache
sudo apt-get install libssl-dev

3. Start compilation

View the details of the current cpu through the lscpu command

Executive order

source build/envsetup.sh
lunch 21  (X86_64 Edition)
make -j8

According to the type of cpu above, make - J cpu cores * 2

4. Troubleshooting process
Mistake 1

void cmdline::logParams(nsjconf_t *)():260 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files

Because I always log in as root under cmd, I always report an error when compiling. Later, I changed the permissions of folder properties to ordinary users, and recompiled as user.

Error two

Follow the prompts to execute make update api-j8 and make again

Error three
java.lang.OutOfMemoryError: Java heap space

I've been looking up this problem for a long time and I haven't found a solution. I guess it's related to the memory of the computer itself. If there's any trouble to solve, please leave a message.

76 original articles published, 47 praised, 20000 visitors+
Private letter follow

Tags: sudo git curl Java

Posted on Sun, 02 Feb 2020 00:02:57 -0800 by slj90