Before beginning this entire process, please ensure you have sufficient storage space. To carry out a single device build an excess of over 30 GB will be required. If building for more than one device, this amount of required storage can exponentially increase. For speedy builds it is highly recommended that you store the sources in a fast storage medium such as Solid State Drives (SSDs), with modern computers it often turns out to be a greater bottleneck than the processor itself when compiling Android.
It should also be noted that in order to build Android from source successfully, you will require GNU Make, git and the Open Java Development Kit as as well as a few build and compiler centric packages, this will vary from distribution to distribution so it is recommended that you 'Google' the required packages for compiling Android for your distribution.
Before you continue, make sure you follow the Setting up a Linux build environment guide. We also recommend you to use CCache for faster builds: Optimizing a build environment
To get started with XOS, you should first become familliar with the basics of the utilities named git and repo, if using a development oriented distro or are already an actual developer working with source based Android ROMs or other similar projects you should more likely than not already have these obtained, if not here's an idea of what one should do below.
Installing repo
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Installing git
Git would more likely than not probably be already installed in your distribution, if it is not then you should try one of the following terminal commands depending on your distribution:
Ubuntu, Debian (apt): apt-get install git
OpenSUSE: zypper install git
Fedora: yum install git-all
Gentoo: emerge --ask --verbose dev-vcs/git
Archlinux: pacman -S git
The derivatives of these common distributions should also have the git package available, if you believe your distribution does not offer git in the default package repositories then you may consider compiling and installing git from source.
First, create a new empty directory of your choice, and cd
into it:
mkdir xossrc
cd xossrc
Of course, you can use any directory name you desire. It is recommended to avoid spaces.
Now initialize a repo source tree, to do this please use following command:
repo init -u https://github.com/halogenOS/android_manifest.git -b XOS-7.1
Then synchronize the source tree using repo, which will fetch the source of XOS. You should be warned that this is a procedure which downloads huge amounts (about 20 GB in total) of data, it may take hours to complete. Be prepared with something fun to do as will be waiting for a while or just listen to EDM. Note, that you will need more than just 20 GB of storage. The download amount of data is <20 GB, the final amount of storage needed, will be around 30-40 GB, and for building XOS, you will need at least additional 35 GB. To clarify: Downloaded will be only 20 GB, and altogether (including the downloaded data) you will need about 90 GB of storage on your hard drive.
repo sync build
source build/envsetup.sh
reposync
Note: The current changelog for XOS is here: https://github.com/halogenOS/android_vendor_xos/blob/XOS-7.1/Changelog.md
First, in order to build XOS you should execute the envsetup.sh script in your terminal/shell, this will set up and import all of the available device configurations for the ROM as well as giving you some fancy "macro" commands for your build enviroment. As such, in order to do this, run the command:
source build/envsetup.sh
Now, you should select and configure the build target by using the lunch command. Type 'lunch', and a list of the available devices and build targets will be offered, give it a whirl, it won't bite.
Additionally here's a list of build types for your target device that you will likely encounter while running 'lunch'.
Build type | Use |
---|---|
user | The flavour usually for building final releases. |
userdebug | Same as "user" but with adb enabled and more debuggable. |
eng | Engineering build, enables shell root access, debuggability, adb, install engineering modules and is fully JIT enabled |
Before you start building, make sure that you have all necessary device-specific trees. Official trees, maintained by the team, can be retrieved using:
breakfast <device>
Example:
breakfast oneplus2
At this point you should be able to build the ROM freely, all that's left to do is enter...
build full XOS_<device>-userdebug
Example:
build full XOS_oneplus2-userdebug
This build
command is a speciality made by the XOS team. It does everything for you, from lunching to breakfasting, and initiating a new build, as well as finding out which amount of threads are optimal for your machine. Hence you must not specify a thread count using -j
on this command, as that will be done automatically for you.
in your terminal, the master chef that is 'Mr Compiler' (aka Ninja) will do the cooking of the ROM for you, this will take another while and depend on your storage speed and the capability of your CPU.
Once done you should find a cute flashable zip either in your directory or within "out/target/product/", this is your creation, you compiled it, she's yours, your own adorable pet... just make sure to treat her very nicely :).
Additional build notes : If you're bringing up a new device, our wiki has some important info
If you do not know how to flash an Android ROM then you probably shouldn't have followed this guide in the first place, or have a case of amnesia, but in the case that you do need a briefing then here's a short guide on flashing XOS: https://goo.gl/BB53SU
For those who know what they are doing: XOS is under development. You can 'sync&build' but there are no promises it will work 100% :P".
###### To build using your GPU (400x faster) do:
export USE_GPU_FOR_BUILDS=true