Ubuntu 22.04 compiled AOSP Android 13

Welcome to my Knowledge Planet Android System Development Guide

Welcome to follow the WeChat public account Wuxian.
Welcome to follow the Zhihu account Wuxian.

Code download

Configuration

Install the tools required to download the code
sudo apt install curl repo git
download configuration repo
mkdir ~/bin/
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo
chmod +x ~/bin/repo


Add the following to the last line of vim ~/.bashrc
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
source ~/.bashrc

Configure the git environment, configure email and name to your own name
git config --global user.email "[email protected]"
git config --global user.name "Your Name"

download

Create a directory to save the code. I downloaded the branch as android-13.0.0_r35. If you want to download other branches, please check
source-code-tags-and-builds

mkdir -p ~/work/android/aosp/android-13.0.0_r35
cd ~/work/android/aosp/android-13.0.0_r35
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/ AOSP/platform/manifest -b android-13.0.0_r35
repo sync -j16
-j The number after -j is the number of threads using the CPU. My computer has 20 threads. I chose 16 to prevent the computer from lagging. The same is true for subsequent compilations.

If an error message indicating that Python cannot be found appears during downloading, please perform the following steps:
sudo apt install python2.7
sudo ln -s /usr/bin/python2.7 /usr/bin/python

code compilation

Compilation tool installation

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

Compile code

cd ~/work/android/aosp/android-13.0.0_r35
source build/envsetup.sh
and select the version you want. If you want to start the emulator, choose the one starting with sdk. For example, aosp_car_x86_64-userdebug cannot start the simulation. For the simulator, sdk_car_x86_64-userdebug can start the simulator
lunch sdk_car_x86_64-userdebug
make -j8
and wait for the compilation to complete. I compiled it for an hour and a half. It should be faster if -j16 is selected.

Start the emulator

After compilation is completed, execute in the same window:
emulator
If you switch the terminal window, execute
source build/envsetup.sh
lunch sdk_car_x86_64-userdebug
emulator -writable-system // -writable-system means that the system is writable, otherwise you cannot adb push the file To the system
The following is a screenshot of the page after startup:

Insert image description here

Code debugging

Debugging tool installation

Install the adb debugging tool
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb
After the installation is complete, execute
adb devices
and you can see that the emulator is running.
Insert image description here

Modify code verification

Let’s change the text on the homepage and first find the path:
packages/services/Car/car-maps-placeholder/res/values/strings.xml
Insert image description here

edit a bit

Insert image description here
By looking at the Android.bp file, we know to compile CarMapsPlaceholder
source build/envsetup.sh
lunch sdk_car_x86_64-userdebug
make CarMapsPlaceholder -j16

After the compilation is completed, push the compiled product apk to the system for verification. First execute
adb root
adb remount
to prompt to reboot the system
Insert image description here
adb reboot.
Then execute
adb root
adb remount
adb push out/target/product/emulator_car_x86_64/system/app/CarMapsPlaceholder/CarMapsPlaceholder.apk /system/app/CarMapsPlaceholder/
Exit the home page and re-enter, and see that our modifications have taken effect.

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_41678668/article/details/129758687