Getting Started With Building AOSP: Difference between revisions
(Created page with "= General Info = This page will briefly describe how to get starting with building android and will use AOSP as the primary example as it is fairly easy to follow and build for pixel devices. = Setting up build environment = For starters you will need to have Linux running on your computer/server and be sure that it is at least ubuntu based. Google officially uses ubuntu and verifies versions for building. If you want the GUI ubuntu desktop is great, and if you plan on...") |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 29: | Line 29: | ||
* downloading from specific branch | * downloading from specific branch | ||
** you can download from a specific branch by placing -b at the end of the initialization command and then typing the name of the branch you are downloading from see example below. | ** you can download from a specific branch by placing -b at the end of the initialization command and then typing the name of the branch you are downloading from see example below. | ||
** You can check for specific tags if needed - [https://source.android.com/docs/setup/about/build-numbers#source-code-tags-and-builds source-code-tags] | |||
** repo init -u <nowiki>https://android.googlesource.com/platform/manifest</nowiki> -b master | ** repo init -u <nowiki>https://android.googlesource.com/platform/manifest</nowiki> -b master | ||
* specifying how many threads | * specifying how many threads | ||
Line 56: | Line 57: | ||
https://source.android.com/docs/setup/build/building | https://source.android.com/docs/setup/build/building | ||
[[Category:Guides]] |
Latest revision as of 16:21, 15 March 2023
General Info
This page will briefly describe how to get starting with building android and will use AOSP as the primary example as it is fairly easy to follow and build for pixel devices.
Setting up build environment
For starters you will need to have Linux running on your computer/server and be sure that it is at least ubuntu based. Google officially uses ubuntu and verifies versions for building. If you want the GUI ubuntu desktop is great, and if you plan on ussing ssh with a server ubuntu server is easy to use and has all the requirements needed as far as the base OS is concerned.
You will need to install more then just a ubuntu base OS, there are a set up scripts that are designed to setup everything required to build with. This may not include 100% of what yo may need. Some roms require other packages to be installed that are not included in these scripts. below is the link to the scripts on Github.
https://github.com/akhilnarang/scripts
Setting up git
You will need to make sure you have git installed and configured. You can follow the directions below for a ubuntu based system
1) Install git
sudo apt install git
2) Configure Git
git config --global user.name [your name] git config --global user.email [your email]
Downloading From Source
Downloading from source means you will be downloading the entirety of the rom you choose. You should at this point create a new folder/directory that you want the rom to be downloaded in and cd into that directory. Afterward you will be using repo to initialize the repo for the rom. For AOSP google says to run the command below to initialize the latest version.
repo init -u https://android.googlesource.com/platform/manifest
After initializing the repo you can now sync the repository which will start downloading the AOSP source code. This will take a long while and though you do not need to running this in a screen ensures that if your ssh connection is lost or your terminal closes for some reason the sync is still running and you do not have to start over again. syncing is easy for AOSP just run the below.
repo sync
repo options
- downloading from specific branch
- you can download from a specific branch by placing -b at the end of the initialization command and then typing the name of the branch you are downloading from see example below.
- You can check for specific tags if needed - source-code-tags
- repo init -u https://android.googlesource.com/platform/manifest -b master
- specifying how many threads
- you can use -j to specify how many threads you want to use for the process. This is generally applicable for more then just syncing but this may be helpful if you want to use half your CPU for some reason. see example below.
- repo sync -j8
- note that 8 threads is going to be 4 cores. if you have a 4 core CPU and type -j16 you are trying to tell it to use more then what is physically available, so make sure you know what your hardware is.
Starting the build
These instructions will assume the building process is for a pixel 7
envsetup - you will need to run the envsetup command in order for your terminal to recognize the build commands and for it to prepare some basic things for building.
. build/envsetup.sh
lunch - AOSP uses the lunch command to kick of the build. This gathers all the information about the device that you are building for and prepares the actual building for the specified device. There are different options you can use. "user" is if it is final and you are building without any extras to make debugging easier. We will be using "userdebug" for this example.
lunch aosp_panther-userdebug
After that is finished you can now start the rest of the build process using the make command which is as simple as
m
if all goes well you should have then built aosp for the pixel 7. This does not create a fastboot flashable image that you may be looking for if you are building for a pixel device. If you want to make the fastboot image you need to run the following.
m updatepackage
Other Roms General
Other roms may use different build commands which they should specify in their android manifest. Most currently use brunch which combines both lunch and make though sometimes you still need to make the update package separately to get the fastboot image if that is what fits best for your device.
Credits
This page is summed up from googles android source pages.