Before I go into details about how to rebuild my ROMs I hope you have setup your development environment already. I guess you know that
- you need a 64bit Linux installation (standalone PC, dualboot PC or virtual machine)
- you need the correct Java version installed
- you need some tools installed to sync the sources and build the ROM
- you need some basic knowledge about github, repo, Android
If you are not prepared yet, please read the following sites first before continuing:
- Downloading and Building – Information about the necessary build environment and guide how to set it up.
- [GUIDE][AOSPA:v3.+] How to Compile AOSPA from Source : + Support and Maintenance – A good tutorial how to setup a build environment
- NLNP’s/Team Radium’s Build Environment Setup Automater Script – Script to setup a build environment
- Learn about the repo tool , manifests and local manifests and 5 important tips ! – Very good tutorial with really helpfull tips for building an Android ROM from sources. I will refer back to this tutorial several times as “Learn Thread”
- Another good guide is [GUIDE] Learning about the Android Build Process. It gives a good introduction into the main commands to build a ROM.
Once you feel familiar with the requirements and your build environment is setup you should create your build folder. I usually give the folder the same name as the ROM, e.g. Ganbarou for my Ganbarou ROMs.
Getting the sources
If you checked out my page where I listed all my ROMs with links for download and to my source, you might have seen that for the source I always link to my ganbarou_tools repository on Github. I did this, because inside this repository you find all tools to download and sync the sources and as well the tools to build the ROM. Even the links seems to be all the same there are differences. Each link goes to a different branch of ganbarou_tools. Each branch is for a different ROM type.
These are the files you usually need to start with:
- ganbarou_tools/tools/roomservice.xml – This is an extension to the manifest.xml
- ganbarou_tools/tools/sync.sh – The batch file to download/sync the source repositories
- ganbarou_tools/create_links.sh – The batch file that copies the build and sync tools into the right place.
This file is an extension to the manifest that is used to download the Android sources. roomservice.xml contents additional repositories that are needed to build a specific ROM for a specific device. “Learn Thread” has a good explanation about this. Search for Maintaining your own projects using manifest.xml in the first post.
To make your first sync easier, create this folder structure inside your build folder:
copy the roomservice.xml file into the folder local_manifests
You should copy this file into the root of your build folder. Make sure the batch file is executable. This batch file starts the download/sync of the repositories that are needed to build the ROM.
After you have successfully synced the repositories, change into the folder ganbarou_tools and start create_links.sh. This batch file copies the scripts for building and maintaining the ROM into the places they are needed.
Start your first sync/download
Now you should be ready to start downloading the first time the sources. If you are downloading the first time this can take a very long time, as you are downloading 15 to 20GB of files. So after you started the synchronisation grab a book, watch a good movie or take a long nap. When I have my real fast connection in Japan (100Mbps) it takes something like 2-3 hours, here in Philippines with 5Mbps, I usually start sync in the evening, let it run over night and hope that it has finished when I wake up for breakfast.
If you have already build a ROM before, e.g. the CyanogenMod ROM, you can reduce the download time by applying the Tip # 2 : Use the reference flag before you initialize a repo ! from “Learn Thread” Just follow the instructions there!
If you have a slow connection or github.com is very busy it can happen that you get error messages for some repositories (repository not found, transfer unexpected finished, …). In this cases you have to repeat the sync/download again. But don’t be afraid, it will only download the missing or changed repositories, not the whole source code.
Once you have finished the initial sync/download of the source repositories successfully, you are ready to try your first build.
Building the ROM
I know it is bad practice, but the name for the script to build varies between my different ROMs.
For Ganbarou ROMs the script name is makeit.sh. It needs some parameters to specify what ROM you want to build:
clean – to build a clean ROM from scratch
tab – to build the ROMs for all variants of the Galaxy Tab 10.1 (GT-P7500, GT-P7510, GT-P7501 and GT-P7511)
3g – to build the ROM for the 3G variants of the Galaxy Tab 10.1 only (GT-P7500 and GT-P7501)
t – to build the ROM for the international 3G variant of the Galaxy Tab 10.1 only (GT-P7500)
wifi – to build the ROM for the 3G variants of the Galaxy Tab 10.1 only (GT-P7510 and GT-P7511)
phone – to build the ROMs for the Galaxy Note, Galaxy S3 and Galaxy S4 (GT-N7000, GT-I9300 and GT-I9505)
s4 – to build the ROM for the Galaxy S4 only (GT-I9505)
s3 – to build the ROM for the Galaxy S3 only (GT-I9300)
n – to build the ROM for the Galaxy Note only (GT-N7000)
all – to build all ROMs listed above
For the Android 4.4.2 ROM for the Galaxy S4 the script name is builds4.sh. No parameters are required.
For the Android 4.4.2 NamelessROM for the Galaxy Tab 10.1 the script name is nameless.sh. It needs some parameters to specify what ROM you want to build:
p4 – to build the ROM for the 3G variants of the Galaxy Tab 10.1 (GT-P7500 and GT-P7501)
p4w – to build the ROM for the 3G variants of the Galaxy Tab 10.1 (GT-P7510 and GT-P7511)
This two parameters cannot be combined. You can build only the 3G or the WiFi version in one call.In addition you can add a second parameter
c – to build a clean ROM from scratch
Good luck with building the ROM. The build scripts explained above copy the final ROM as a flashable ZIP file into your build folder.
After you have build the ROM you will see new folder “out” in your build folder. In this folder are all compiled and processed files stored that were created during the build process. If you just build the ROM a second time, the build process will be very fast, because these files are reused. Only changed source files are compiled or processed again. This makes the build faster if you have only smaller changes in the source codes.
But sometimes this leads to problems in the final ROM. I recommend therefor at least for release versions to make a clean build. This means that all files in the folder out are discarded and the ROM sources are compiled and processed from scratch. This of course takes a longer build time.
To make a clean build you can either use the provided parameter in the build script or simply delete the complete out folder before you start the build.
How to maintain the source code
So now you are able to build the ROM, flash it to your device and (hopefully) enjoy it. But what about updates? Android sources as well as 3rd party ROM sources are frequently updated. You can see bugfixes, improvements or new features every week.
To update your sources to the latest version you simply use the sync.sh script again. It will compare your local repositories with the online ones and download changed files.
To build a ROM with the updated sources you follow the instructions in “Building the ROM” again. I recommend to make s clean build after you updated the sources. A clean build means that all the compiled and processed files in the folder out are discarded and Some of my scripts offer a parameter to force a clean build. But you can as well just delete the complete out folder to force a clean build.
This page will be updated soon with