Ubuntu20.04 guide to compiling Android 10 source code and burning it to pixel3

  • Experimental environment
    • Download the Android source tree
    • Install the mobile driver version on pixel3
    • Compiling Android source code
    • Android Studio import Android system source code
    • Importing source code into Android Studio is slow
    • Swipe in the image file you just compiled on Pixel3
    • From the pit
    • Final rendering

Experimental environment

  1. Ubuntu20.04
  2. pixel3

Download the Android source tree

You can choose to download the latest version of The Android source code, or you can download a specific branch. If we can use scientific advice in Google’s online source tree to download, if not recommended to use tsinghua mirror: mirrors.tuna.tsinghua.edu.cn/help/AOSP/, use mirror tutorial link has been given in detail, here is a tautology

  1. Download the REPO tool:
// Download the repo tool
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Copy the code
  1. After you install the Repo, set up your own client to access the code base: sign up for a Google account yourself
(1) Create a folder to store the source codeCopy the code
mkdir Pixel3
cd Pixel3
Copy the code
(2) Use your Google account and real name to configure GitCopy the code
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Copy the code
(3) Run repo init to get the latest version of the code or specify a branchCopy the code
repo init -u https:/ / android.googlesource.com/platform/manifest / / get the latest source code
repo init -u https:/ / android.googlesource.com/platform/manifest - b android - 10.0.0 _r1 / / specified branch
Copy the code
  1. Download the Android source tree
repo sync
Copy the code

Install the mobile driver version on pixel3

  1. inwebsiteFind on with the phone model as wellAndroid source code Build numberCorresponding driver version

    The source code I downloaded here is Android-10.0.0_R1, so its Build number is Qp1A.190711.019



    Then go to the official driver website to find the corresponding driver information and download it

  2. Unzip to the source code root directory you just downloaded
  3. Enter the following code in the command line, and press Enter to read the protocol. However, because the protocol is too long, you can press CTRL + C to interrupt the protocol. The message will prompt you to enter I ACCEPT, and then you can extract the image
./extract-google_devices-blueline.sh
./extract-qcom-blueline.sh
Copy the code

  1. After successful extraction, the vendor directory will be generated in the root directory

Compiling Android source code

Note that compiling the source code requires at least 16GB of memory, so you need to add a swap partition, as detailed in my first post

source build/envsetup.sh
lunch aosp_blueline-userdebug
make -j12
Copy the code

Android Studio import Android system source code

  1. After successful compilation, run the following command to compile the source idegen module and generate AS configuration (*ipr) :
mmm development/tools/idegen/
development/tools/idegen/idegen.sh
Copy the code

Iml (used to record modules, dependencies, and SDK versions included in the project) Android. ipr (project details, code, and lib dependencies) Android. iws (personal configuration information)

  1. Change android. Iml Android. Ipr to 777
sudo chmod 777 android.iml
sudo chmod 777 android.ipr
Copy the code
  1. Open Android Studio, import the existing project, and select the. Ipr file in the root directory

Importing source code into Android Studio is slow

sudo vim /etc/sysctl.conf
Copy the code

After entering the file, press I to enter edit mode

Add at the end of the file

fs.inotify.max_user_watches = 524288
Copy the code

Press Esc to enter normal mode, press: and then enter wq.

Effective file

Sudo sysctl -p - system// Valid file
Copy the code

Swipe in the image file you just compiled on Pixel3

  1. Connect pixel3 to your computer and enter bootloader mode
adb reboot bootloader
Copy the code
  1. Unlock the phone
fastboot flashing unlock
Copy the code
  1. Enter fastBooTD mode,The reference documentation is

// (1) Method 1: Enter a value in bootloader mode
fastboot reboot fastboot
Copy the code
// (2) Method 2: Return to the Android operating system and run the following command
adb reboot fastboot
Copy the code
  1. Enter the following command on the command line
source ./build/envsetup.sh
Copy the code
  1. Enter the following command on the command line
lunch aosp_blueline-userdebug
Copy the code
  1. Go to the generated product path and type the following command on the command line
cd  $ANDROID_PRODUCT_OUT
Copy the code
  1. To burn the compiled image file, enter the following command on the command line interface
fastboot flashall -w 
Copy the code

From the pit

  1. When choosing a phone to swipe, don’t buy the us version of pixel2, its bootloader won’t unlock, and you’ll need to buy the European version to swipe the pixel2
  2. If you have to do 3 or 4 steps before entering the image on pixel3, you will encounter “Value too large for defined data Type “when loading the image.
  3. “Partition should be flashed in fastbootd”
  4. : If the phone originally runs Android 11, burning an Android 10.0 image file to the device will fail. First go to the official website to burn the compiled source branch base package (Factory images), and then burn the Android 10.0 image file
  5. If “Wait for any devices” is displayed after the FastBoot flashAll -w input, then the steps of loading the newly compiled image file on Pixel3 should be performed under root permission.

Final rendering

Reference link blog.csdn.net/weixin_4576… Developers.google.com/android/dri… Source. The android. Google. Cn/devices/boo… www.jianshu.com/p/1f4a2b182…