FORUMS
Remove All Ads from XDA

[GUIDE] Build any Custom ROM from Source [Noobfriendly]

202 posts
Thanks Meter: 264
 
By notiflux, Senior Member on 15th August 2015, 03:18 PM
Post Reply Email Thread
I know there are many of these guides on XDA, but when I wanted to learn how to compile ROMs, all those guides didn't help me out cause all those guides are for more advanced users. I will try to explain every step clearly.


Step 1: Prepare your PC for building Android

Here's a good guide how to do that. http://forum.xda-developers.com/show....php?t=2639611
Follow this guide up to step 9, then return to this thread.


Step 2: Downloading the sources

First, in terminal type "mkdir <android>" and then "cd <android>". Replace <android> with the ROM name that you want to build. For example if you want to build omni, type "mkdir omni" and "cd omni". Now you created a directory called "omni" and switched to it. Now, pick a ROM that you want to build and go to its github page. Then search for a repository that has the word "manifest" in it (sometimes it's also just called "android"). Click on it. On the top, select the branch. Most times every branch is for a different android version. Select the latest android version (For this guide it's Android 5.1.1, so the branch most times is LP-5.1). Then scroll down to the readme, copy the command starting with "repo init" and paste it in your terminal. Now just type "repo sync" and it will download the sources. This will take time, since it's about 15gb that will be downloaded.


Step 3: Download the Device specific sources

Next, you have to download the device tree, the kernel and the vendor files. If you're lucky, someone already put together a roomservice.xml for your device where all the needed stuff is declared. Search for "<devicename> roomservice" and hopefully you'll find a github page with this file. If you do, download it and push it to <android>/.repo/local_manifests/. Then go back to the terminal and type "repo sync" again. This time it won't take that long. If there's no roomservice.xml for your device, You have to create it. The device tree and kernel most times can be found by going to github.com/CyanogenMod and searching for your brand. For example, if you have a Motorola Moto G 2nd Generation (codename titan), search for motorola and open android_device_motorola_titan (sources for titan), android_device_motorola_msm8226-common (sources for titan's chipset) and android_kernel_motorola_msm8226 (sources for the kernel of the chipset) in a new tab. Also you need the vendor files which can be found at github.com/TheMuppets. For motorola devices, open proprietary_vendor_motorola. Create a new file on your desktop called "roomservice.xml" and open it. Paste this:

Code:
 <?xml version="1.0" encoding="UTF-8"?>
  <manifest>

    <project name="" path="" remote="github" revision="cm-12.1" />
    <project name="" path="" remote="github" revision="cm-12.1" />
    <project name="" path="" remote="github" revision="cm-12.1" />
    <project name="" path="" remote="github" revision="cm-12.1" />
  </manifest>
Then go back to the github pages, copy the names of the repositorys and paste <project-name-on-github>/<name-of-the-repository> in the quotes after "name=". For titan, it would look like this:

Code:
  <?xml version="1.0" encoding="UTF-8"?>
  <manifest>

    <project name="CyanogenMod/android_device_motorola_titan" path="" remote="github" revision="cm-12.1" />
    <project name="CyanogenMod/android_device_motorola_msm8226-common" path="" remote="github" revision="cm-12.1" />
    <project name="CyanogenMod/android_kernel_motorola_msm8226" path="" remote="github" revision="cm-12.1" />
    <project name="TheMuppets/proprietary_vendor_motorola" path="" remote="github" revision="cm-12.1" />
  </manifest>
Now for the path, just copy the name of the repository, remove "android_" or "proprietary_" and replace each "_" with a "/"

Code:
  <?xml version="1.0" encoding="UTF-8"?>
  <manifest>

    <project name="android_device_motorola_titan" path="device/motorola/titan" remote="github" revision="cm-12.1" />
    <project name="android_device_motorola_msm8226-common" path="device/motorola/msm8226-common" remote="github" revision="cm-12.1" />
    <project name="android_kernel_motorola_msm8226" path="kernel/motorola/msm8226" remote="github" revision="cm-12.1" />
    <project name="proprietary_vendor_motorola" path="vendor/motorola" remote="github" revision="cm-12.1" />
  </manifest>
Sometimes you need some more repositorys, for example for titan you also need android_hardware_qcom_fm and android_device_qcom_common. Add them the same way as you added all the other sources. You can find out which repositorys you need by opening cm.dependencies in your decive- and chipset sources.
Now save the file and push it to "<android>/.repo/local_manifests/". Now return to your terminal and type "repo sync" again.


Step 4: Edit the device tree

You have to edit the device tree so that it fits to the ROM that you want to build. Go to <android>/vendor. In there you will find a folder with the abbreviation for the ROM. For example for CarbonROM the abbreviation is carbon, for EuhoriaOS it's eos, for AOKP it's aokp and for CyanogenMod it's cm. Remember this abbreviation. Back in terminal, type "cd device/<brand-you-are-building-for>/<phone-you-are-building-for>/" and then "mv cm.mk <remembered-abbreviation>.mk" and "mv cm.dependencies <remembered-abbreviation>.dependencies". After that, type "nano <remembered-abbreviation>.mk" and replace "cm" with "<remembered-abbreviation>" where ever you see it. To save the file, hit Ctrl+O, then Enter and then Ctrl+X. Now type "cd .." and then "cd <chipset-you-are-building-for>. Now, type "mv cm.dependencies <remembered-abbreviation>.dependencies" again.


Step 5: Building

We finally arrived there! To build our ROM, in terminal type ". build/envsetup.sh" and then "brunch <codename-for-your-device>".

This process takes time, depending on your PC specs. On my PC (2 cores, 3gb RAM), building takes about 8h. On my friends Server (12 cores, 128gb RAM), building takes about 20 mins.

Happy building!

Credits:
@Sarath280 for teaching me how to build ROMs
My dad for teaching me everything else aboout technology
@sylentprofet for the guide how to prepare linux to build Android
The Following 7 Users Say Thank You to notiflux For This Useful Post: [ View ] Gift notiflux Ad-Free
 
 
30th January 2016, 04:58 PM |#2  
AmolAmrit's Avatar
Senior Member
Flag Patna
Thanks Meter: 3,812
 
More
@notiflux
Het Max, Amol here. Thank You So Much. Love ya.

Sent from my Moto G 2014 using Tapatalk
The Following 2 Users Say Thank You to AmolAmrit For This Useful Post: [ View ] Gift AmolAmrit Ad-Free
16th April 2016, 05:09 PM |#3  
Junior Member
Thanks Meter: 2
 
More
Thanks! For this great tutorial! I am testing it right now I had problems making the roomservice.xml but with this tutorial it was very easy .
I am using a china device so not so many ROMs avalible so I am building one myself
The Following User Says Thank You to AnStu00 For This Useful Post: [ View ] Gift AnStu00 Ad-Free
8th August 2016, 05:11 PM |#4  
sscsps's Avatar
Senior Member
Flag delhi
Thanks Meter: 185
 
More
Hello @notiflux,
Thanks for the guide,
I have a little issue though,
The thing is that the device that i want to build the rom for(SM-T211) DO NOT have a device tree already built. So I need to make that first. Can you help me with that?
9th August 2016, 06:29 PM |#5  
notiflux's Avatar
OP Senior Member
Flag G├╝tersloh
Thanks Meter: 264
 
More
Quote:
Originally Posted by sscsps

Hello @notiflux,
Thanks for the guide,
I have a little issue though,
The thing is that the device that i want to build the rom for(SM-T211) DO NOT have a device tree already built. So I need to make that first. Can you help me with that?

I'm not really into that kinda stuff since I never worked on such a device, but I know that there are guides here on xda on how to create your own device tree. But I think your device needs to be rooted for that
http://forum.xda-developers.com/show....php?t=2010281 you can try this guide. Good luck!
The Following User Says Thank You to notiflux For This Useful Post: [ View ] Gift notiflux Ad-Free
RahulMantha
23rd February 2017, 05:24 PM |#6  
Guest
Thanks Meter: 0
 
More
help in source tree
Sir, i downloaded ,android aosp open source tree ,,in desktop directory ,,linux 16:10 ,next i downloaded open source ,,kernal and android files from lg website ,,as i am using lg ,,,in open source lg ,,i got 2 tar files,,1 android ,2nd is kernal tar,,and ine readme.txt i opened it ,,it showing that untar android. tar and merge ,in download.android source tree ,,but where i am not getting ,,please tell me where ,,please sir
25th February 2017, 01:55 AM |#7  
Senior Member
Thanks Meter: 42
 
More
I see this thread is from 2015, does the guide work for nougat also?
2nd October 2017, 11:06 PM |#8  
Member
Thanks Meter: 2
 
More
Any solution for this error?

Code:
Starting build with ninja
ninja: Entering directory `.'
ninja: error: '/home/harshone/android/lineage/out/target/product/m8/obj/KERNEL_OBJ/usr', needed by '/home/harshone/android/lineage/out/target/product/m8/obj/STATIC_LIBRARIES/libsdcard_intermediates/sdcard.o', missing and no known rule to make it
build/core/ninja.mk:151: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1
make: Leaving directory '/home/harshone/android/lineage'

#### make failed to build some targets (02:30 (mm:ss)) ####
18th December 2017, 02:17 PM |#9  
DroidHero2002's Avatar
Senior Member
Flag Halifax
Thanks Meter: 51
 
Donate to Me
More
Hi, how do I apply security updates to the source?
24th January 2018, 06:23 AM |#10  
karthik km's Avatar
Recognized Developer
Flag Bangalore
Thanks Meter: 2,057
 
Donate to Me
More
Quote:
Originally Posted by HarshOne

Any solution for this error?

Code:
Starting build with ninja
ninja: Entering directory `.'
ninja: error: '/home/harshone/android/lineage/out/target/product/m8/obj/KERNEL_OBJ/usr', needed by '/home/harshone/android/lineage/out/target/product/m8/obj/STATIC_LIBRARIES/libsdcard_intermediates/sdcard.o', missing and no known rule to make it
build/core/ninja.mk:151: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1
make: Leaving directory '/home/harshone/android/lineage'

#### make failed to build some targets (02:30 (mm:ss)) ####

It seams you don't have libsdcard folder/file in your device tree.
So try to search and download that file from github.

then copy and paste that file to your device tree
7th August 2019, 09:53 AM |#11  
Junior Member
Thanks Meter: 0
 
More
Hello respected developers,

I'm very enthusiastic and inspired by viper os to develop it for my other devices too. But first I tried to build the rom for my redmi 4a because i wanted to test the success of my building. I would like to inform you that i have gone through every process of establishing environment to reposync all learnig from aosp document and manifests on the viper os github and even downloaded device tree,vendor and kernel as from git hub . and i made neccessary edits to androidproducts.mk , lineage_rolex.mk to naming viper_rolex.mk and setting device path.
And finally i proceeded by :
Code:
./build/envsetup.sh
lunch viper_rolex-userdebug
mka poison
The build process then followed for about 5 hrs and i was hopefully waiting close success but alas! I came up with a error given this way:

Warning: Stripped invalid locals information from 2 methods.
In /home/shrawan/Desktop/workon_viper/out/soong/.intermediates/frameworks/base/packages/EasterEgg/EasterEgg/android_common/combined/EasterEgg.jar:kotlin/collections/SlidingWindowKt$windowedIterator$1.class:
Methods with invalid locals information:
java.lang.Object kotlin.collections.SlidingWindowKt$windowedIterato r$1.doResume(java.lang.Object, java.lang.Throwable)
In /home/shrawan/Desktop/workon_viper/out/soong/.intermediates/frameworks/base/packages/EasterEgg/EasterEgg/android_common/combined/EasterEgg.jar:kotlin/sequences/SequencesKt___SequencesKt$zipWithNext$2.class:
Methods with invalid locals information:
java.lang.Object kotlin.sequences.SequencesKt___SequencesKt$zipWith Next$2.doResume(java.lang.Object, java.lang.Throwable)
Some warnings are typically a sign of using an outdated Java toolchain. To fix, recompile the source with an updated toolchain.
[ 82% 60970/74331] build /home/shrawan...icy_tests_intermediates/sepolicy_tests
FAILED: /home/shrawan/Desktop/workon_viper/out/target/product/rolex/obj/ETC/sepolicy_tests_intermediates/sepolicy_tests
/bin/bash -c "(/home/shrawan/Desktop/workon_viper/out/host/linux-x86/bin/sepolicy_tests -l /home/shrawan/Desktop/workon_viper/out/host/linux-x86/lib64/libsepolwrap.so -f /home/shrawan/Desktop/workon_viper/out/target/product/rolex/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts -f /home/shrawan/Desktop/workon_viper/out/target/product/rolex/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts -p /home/shrawan/Desktop/workon_viper/out/target/product/rolex/obj/ETC/sepolicy_intermediates/sepolicy ) && (touch /home/shrawan/Desktop/workon_viper/out/target/product/rolex/obj/ETC/sepolicy_tests_intermediates/sepolicy_tests )"
The following types on /data/ must be associated with the "core_data_file_type" attribute: netmgrd_data_file

[ 82% 60975/74331] //bionic/libc:commo...ioner preprocess include [linux_glibc]
warning: attempted to generate guard with empty availability: obsoleted = 23
warning: attempted to generate guard with empty availability: obsoleted = 21
ninja: build stopped: subcommand failed.
11:58:35 ninja failed with: exit status 1

#### failed to build some targets (04:38:04 (hh:mm:ss)) ####




I did a enough of the search in and out of the forum but i couldn't able to know what problem is this and i dont have any idea how to solve this. Please give me some light on what problem is this and guide me where should i be looking to solve. I have a great enthusiasm of learning but this problem solution isn't available or discussed properly in any place or maybe i didn't find the place where to look. Please help me on this
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes