The preparatory work
1. The VirtualBox, download address www.virtualbox.org/wiki/Downlo… My version is 6.0.20. 2.Ubuntu18.04 Download ubuntu.com/download/al… My version is 18.04LTS 3.Nexus 6P, you have the new Google phone is ok, other phones are not available without the corresponding driver
- Note: It is best to allocate more than 200G disk space to Ubuntu. My computer has 16G memory to allocate 8G memory to Ubuntu (memory is too small to compile). My computer CPU is i5-4590, so I allocate 4 processors to Ubuntu. The disk size cannot be changed after being allocated, the memory and processor count can be adjusted in Settings after shutting down the VM.
1. Download the REPO tool
-
Install git, OpenJDK-8, python, and other tools
sudo apt-get update
sudo apt-get install git
sudo apt-get install openjdk-8-jdk
sudo apt-get install python
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 Copy the code
-
Configure repo
mkdir ~/bin
PATH=~/bin:$PATH
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
2. Download source code
-
To create the source directory, go to mkdir aosp CD aosp
-
The reO configuration is updated using a mirror source for tuna, which copies the following to the end of your ~/.bashrc: 1). The command line is opened through gedit. Bashrc file gedit ~/.bashrc 2). Will export REPO_URL = ‘https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/ paste at the end of the 3). Run the source ~/. Bashrc command to refresh environment variables
-
Git config –global user.email “[email protected]” git config –global user.name “username”
-
Initialize the warehouse: repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
-
Initialization and specify the version, because I am a Nexus 6 p cell phone, so download Android must support the Nexus 6 p, corresponding relation to check the address: source. The Android. Google. Cn/setup/start…
Repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest - b android - 7.1.1 _r27
repo sync
3. Compile source code
After a long wait we completed the source code synchronously, next compilation:
- If android 6.0~8.1, return to the source directory to configure jack-admin
1). Check the doctor and open jack service./prebuilts/sdk/tools/jack-admin list-server prebuilts/sdk/tools/jack-admin start -server prebuilts/sdk/tools/jack-admin stop -serverCopy the code
2). If the command does not exist. If yes, run the following command:
cdPrebuilts/SDK /tools/./jack-admin install-server jack-launcher. Jar Jack-server-4.8.alphaCopy the code
After the installation is complete, restart it.
- Begin to compile
1) script initialization environment:source build/envsetup.sh
2). Delete the result of the previous compilation, the first compilation may not need this step:make clobber
3). Select the compile targetlunch Copy the code
The following information is output:
You're building on Linux Lunch menu... pick a combo: 1. aosp_arm-eng 2. aosp_arm64-eng 3. aosp_mips-eng 4. aosp_mips64-eng 5. aosp_x86-eng 6. aosp_x86_64-eng 7. full_fugu-userdebug 8. aosp_fugu-userdebug 9. mini_emulator_arm64-userdebug 10. m_e_arm-userdebug 11. m_e_mips64-eng 12. m_e_mips-userdebug 13. mini_emulator_x86_64-userdebug 14. mini_emulator_x86-userdebug 15. aosp_dragon-userdebug 16. aosp_dragon-eng 17. aosp_marlin-userdebug 18. aosp_sailfish-userdebug 19. aosp_flounder-userdebug 20. aosp_angler-userdebug 21. aosp_bullhead-userdebug 22. hikey-userdebug 23. aosp_shamu-userdebug Which would you like? [aosp_arm-eng]Copy the code
BUILDTYPE = aoSP_arm-eng BUILD type = AOSP_ARM BUILD type = ENG BUILD type = eng
Where BUILD indicates the environment in which the compiled image can run, AOSP represents the Android open source project, and ARM indicates that the system runs on the PROCESSOR of ARM architecture. More official documents (source. Android. Google. Cn/source/runn…). . BUILDTYPE refers to build types, and there are three:
- User: the version used for official release to the market. If you do not have the root permission, you cannot dedug and ADB is disabled by default.
- Userdebug: Enables root and debug permissions based on the user version. Adb is enabled by default. Generally used for debugging the real machine.
- Eng: Developer’s version, with maximum permissions (root, etc.), with additional debugging tools for development configuration. Generally used in simulators. If you don’t have a Nexus device and just want to BUILD and run it in the emulator, then BUILD can be aoSP_x86 and BUILDTYPE eng, Which would you like? [AOSP_ARM-eng] directly enter the corresponding serial number 5.
My phone here is Nexus 6P. Check the corresponding table and you can see that the supported format is AOSP_Angler – userDEBUG, so I enter 20 and press Enter. Begin to compile
make -j4
Copy the code
-JN was set according to its CPU core and waited for the compilation to complete. The compilation took about 4 hours due to poor performance of my computer
5). Eventually in the source directory with the out/target/product/angler generated image file directory: * system. Img: system image * ramdisk. Img: root file system image * userdata img: Img :recovery image * boot.img: boot image * vendor.img: driver image
4. The flash
-
Connect the PC to the mobile phone and start the FastBoot ADB reboot bootloader
-
Img, System. img, recovery.img and Vendor. img were copied to Windows, and we only scanned these image files.
-
Skip this step if the phone is unlocked
# For new devices (devices released in 2015 and later) fastboot flashing unlock # For older devices (devices released in 2014 and before) fastboot oem unlock Copy the code
-
Configure adb environment variables, or go to the ADB directory and execute commands
Img fastboot flash system {system.img fastboot flash recovery {recovery.img fastboot flash boot {boot.img Fastboot flash vendor {vendor.img path}Copy the code
Restart the phone to complete the refresh.
Reference links: www.jianshu.com/p/4df53ed23… Blog.csdn.net/qq_35460159… Liuwangshu. Cn/tags/AOSP based…