Article directory
There are many excellent articles circulating on the Internet about Android system source code compilation. The main reason why I want to write this is to record the process of compiling the system. Here, I will take Android 9.0 and the Piexl generation mobile device as an example to describe the compilation and flashing process.
1. Environmental preparation
ubuntu18.04
memory at least 12G RAM
hard disk space at least 200GB
2. Download Android source code
(1) Install python
apt-get install python (Repo 是基于 Python 2.x 中的特定功能构建的,与 Python 3 不兼容。要使用 Repo,请安装 Python 2.x:)
(2) Install Git & configure Git information
sudo apt-get install git
git config --global user.name (Your Name)
git config --global user.email ([email protected])
(3) Install curl
sudo apt-get install curl
(4) Download repo
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=~/bin:$PATH
(5) Create a source code storage directory
mkdir /home/ubuntu/aosp (根据实际情况来新建目录)
cd /home/ubuntu/aosp
(6) Initialize the warehouse
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
(7) repo specifies the Android version
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r46
(8) Synchronization source code
repo sync (等待源代码下载完成,长时间等待,若失败请检查网络等情况)
3. System compilation
(1) Install openjdk8
sudo apt-get install openjdk-8-jdk (安装不成功检查ubuntu是否换源、是否有更新软件包列表)
(2) Install dependencies
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
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 lib32z-dev ccache
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
(3) Set and enable ccache (to speed up recompiling source code. Optional)
sudo apt install vim
export USE_CCACHE=1 (在你home主目录的.bashrc中加入)
export CCACHE_DIR=/home/ubuntu/.ccache (指定一个缓存目录,也可以不指定,默认目录为你当前用户目录下的.ccache)
aosp/prebuilts/misc/linux-x86/ccache/ccache -M 50G (这个命令在Android源码中,缓存大小按照自己的硬盘来适当调整)
source ~/.bashrc (source命令使修改立即生效)
(4) Download mobile phone driver
a. Check the source code tag and build version to check the appropriate driver version for download.
b. From the picture above, you can see that you need to download the driver of QP1A.190711.019 (here we take piexl 2 and android10.0.0_r1 as examples, please download according to the actual situation), find the driver and download it .
c. Unzip the downloaded file and place it in the source code root directory, and authorize the execution of the sh file. After running, you will be prompted to view the certificate. Press the Enter key to view it line by line. When the input prompt appears, enter I ACCEPT and extract it to the vendor directory.
./extract-google_devices-sailfish.sh
./extract-qcom-sailfish.sh
(5) Start compilation
source build/envsetup.sh
lunch
lunch 47 (lunch选定的版本按照实际情况来)
make -j16 (和cpu有关,适当调整数字)
(6) Complete the compilation logo
#### build completed successfully (01:35:28 (hh:mm:ss)) ####
4. Flash the machine
After compiling the system for the real machine, you can find the fastboot tool in the /aosp/out/host/linux-x86/bin directory
(1) Set environment variables
The directory where the compiled system image is located
export Android_PRODUCT_OUT=/home/jhan/aosp/out/target/product/sailfish
(2) Flash the image
fastboot flashall -w (手机要解BL锁且进入bootloader后执行此命令)
5. Error reporting and sorting
Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files
When reporting an error, go up to "/bin/bash"
https://www.yisu.com/zixun/366049.html