Android 10 (q) system source code compilation

I. hardware environment

In Ubuntu 18 The following conditions are required to download and compile the Android 10 (q) source code in the system
1. At least 4G memory, less than 4G memory. Waiting during compiling the source code will be very painful
2. At least 200G hard disk, the larger the better
I used a virtual machine in the compilation process. 150 hard disks were allocated for the first compilation, which was not enough. Finally, I had to reinstall the system for three days, and the system allocated 500G hard disks to start the compilation. During the compilation, I checked the use of hard disks, and the maximum use of 150G hard disks was 200G, which should be enough

II. Software environment

Android 10 needs to be compiled with open source openJDK instead of oracle JDK
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 through the following command

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

2. Install dependent Libraries

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. Install GIT

sudo apt-get install git

4. Set GIT account

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

5. Install python

sudo apt-get install python

6. Configure the PATH environment variable

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

7. 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

8. Create working directory

  mkdir android  //The name of the working directory should be chosen according to your preference
  cd  android

9. Add Tsinghua University image source

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

10. Initialize the warehouse and specify the android version to download

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

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
Or repo init -u git://aosp.tuna.tsinghua.edu.cn/aosp/platform/manifest
The default download is the latest version
If prompted, you cannot connect to Gerrit googlesource. COM, you can edit ~ / bin/repo to replace repo_ Replace the URL line with the following: REPO_URL = ‘ https://gerrit-google.tuna.tsinghua.edu.cn/git-repo ’
To download a specific version, use the following command
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-10.0.0_r10
//-b followed by the version number you want to download
11. Synchronization source code

repo sync -j8

The next step is a long wait. The length of time depends on your character. Wait slowly. If there is a problem with the download halfway, you can ctrl+c exit the download and execute it again
I will download android-10.0 from 100M optical fiber until the repo sync command is downloaded 0_ R10 source code took eight hours a night

Third, start compiling

1. Execute the compilation environment script under the root directory of the source code

 source build/envsetup.sh

2. Execute the lunch command and select the version to be compiled

lunch

3. Start compiling

make -j16

It usually takes two to three hours to wait for the compilation to complete, depending on the machine configuration. If there is a problem during the compilation, I believe Baidu doesn't need my teaching
4. Start the simulator

emulator &

After the compilation is successful, execute this command to start the simulator to view the compiled system

IV. problems encountered

1,libncurses.so.5 and libtinfo so. 5 not found

error while loading shared libraries:libncurses.so.5: cannot open shared object file:No such file or directory
error while loading shared libraries: libtinfo.so.5: cannot open shared object file:No such file or directory

There are two possibilities that the library cannot be found. One is that it is not installed (sudo find -name "libncurses.so.5" is found in the system root directory), and the other is that it is installed but not configured in the system search path.
You can find these two files in the Android 10 source code by searching, so you can directly establish two soft connections for the system to search.

sudo ln -s /home/cxp/work/aosp_android0.0.0_r33/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot/usr/lib/libncurses.so.5  /lib/libncurses.so.5
sudo ln -s /home/cxp/work/aosp_android0.0.0_r33/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot/usr/lib/libtinfo.so.5  /lib/libtinfo.so.5

2. api problems

Killed
-e
******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
   1. You can add '@hide' javadoc comments to the methods, etc. listed in the
      errors above.

   2. You can update current.txt by executing the following command:
         make system-api-stubs-docs-update-current-api

      To submit the revised current.txt to the main Android repository,
      you will need approval.
******************************

Solution: execute the following statement and recompile

make system-api-stubs-docs-update-current-api

Links:
Open source software mirror station of Tsinghua University

Statement:
This article is original content, welcome to reprint, please indicate the source, thank you!

Keywords: Linux Android

Added by cutups on Tue, 28 Dec 2021 00:38:07 +0200