[Motorola Droid RAZR] tonyt.:
This guide is referred to people who don’t know anything about building ROMs.

ROM Building Guide

Index

-Prepare building enviroment

-Install necesary packages

-Syncronize repos from ROM

-Put all the dependecies for Device

-Making NON-CM based ROMS

-Make Changes on BASE to build

-Commands for build

-Build

-Errors, Bugs and Fails

Prepare building enviroment​

First of all we need to have a prepared enviroment for build, normally if you install Ubuntu you need to download manually some programs like SDK, Phyton and other tools, but this is a really easy guide so we use a preconfigured SO in order to have most of the things configured and downloaded.

We need to download this ISO and install it on our machine:

http://www.mediafire.com/download/h5t5mbht8d85dbq/builduntu.v12.iso

install it is so easy so only burn the iso into a disk and install it.

If you don’t want to install Ubuntu in your machines you can use a Virtual Machine, if you want to use a VM you have to download this:

http://nathanpfry.com/builduntu-virtual-machine-android-rom-compiling/

Extact it and you will see a ova file, go to VM VirtualBox and then press “ctrl” + “I” and find .ova file and import it. When this finish go to “configuration” and give the machine 4GB of RAM or more and 2 processors or more.

*It’ll work anyway if you set 2GB of RAM but if you put more, much more faster the rom will build*

Install necesary packages​

If you choose VM continue to the next step.

If you choose Native OS(or secondary boot), when you finish installing Ubuntu you have to open a “terminal” and put this:

mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

This will install “repo” to use it later.

When this finish use nano to edit ~/.bashrc

sudo nano ~/.bashrc

And scroll down at the very bottom and add this into a new(empty) line:

export PATH=~/bin:$PATH

Save it. In nano that would be Ctrl-O and then Enter. Then Ctrl-X to exit back to a prompt. Restart bash:

source ~/.bashrc

And this is all :D

Syncronize repos from ROM​

Okay, we have the enviroment, so now we need to set up the ROM, and I have to tell you that we only have to use Terminal, Firefox and File Manager. First of all you need to know that for linux is not the same if write things in capital letter, so if you can do anything or terminal didn’t recognize your command see this first. I’ll teach you some commands:

mkdir

mkdir ~/

This command will make a new folder, after “/” you have to put the name of the new folder, where all the repos will be. For example I want to make a folder named DU:

mkdir ~/DU

cd

cd ~/DU

This will open this folder to work on it in my case “DU”

*note “~/DU” this made my folder into “home”

repo init

repo init

This command will initializate the repo this will change depending the rom that you want to build, some examples:

DU

repo init -u https://github.com/DirtyUnicorns-KitKat/manifest.git -b du44

AOKP

repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat

AOSB

repo init -u https://github.com/AOSB/android.git

To find the repo for specific rom you have to find the manifest like this:

https://github.com/AOSB/android/tree/android-4.4

https://github.com/AOKP/platform_manifest

repo sync

repo sync

This will download and make all the files to build a rom(sync one rom maybe tooks hours because the size of all the repo is about 10GB or more, depending wich ROM pick)

This command will be the same for all roms(but some roms made a change, but you will be noticed in the manifest)

And last thing to know is that all the files and manifest files are on:

https://github.com/

(it’s recomended to make an account here)

Ready continue, we need to make a folder to download the repos, I want to make DU(you can put the name that you want, remember the use of capital letters):

mkdir ~/DU

Then I have to make DU my working folder:

cd ~/DU

And initializate the repo:

repo init -u https://github.com/DirtyUnicorns-KitKat/manifest.git -b du44

(remember to find the repo command for your rom in the manifest file, if you don’t find it Google it)

You will see that some files were downloaded.

IMPORTANT: Maybe you need to make an account and a password to download the repos from github.

Then type this:

repo sync

And all the repos will be downloaded.

Maybe you will see that some repos didn’t download well or in terminal appears “fatal” so make “repo sync” twice(the second time will be much more faster that the first).

Put all the dependecies for Device​

So we have all the repos for build the rom in our HDD, now we need to download the files to build the rom to our device.

Well in this part some roms admit to download teh device from Cyanogen and others not, so the easy way(try this first) is this:

Go to your working folder with "file explorer" and open ".repo", here create a folder named "local_manifests" open it and make a text file named "roomservice.xml"(yes, its "room") and inside the file paste this as I provide:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="CyanogenMod/android_device_motorola_umts_spyder" path="device/motorola/umts_spyder" remote="github" revision="cm-12.0" />
<project name="CyanogenMod/android_device_motorola_omap4-common" path="device/motorola/omap4-common" remote="github" revision="cm-12.0" />
<project name="CyanogenMod/android_kernel_motorola_omap4-common" path="kernel/motorola/omap4-common" remote="github" revision="cm-12.0" />
<project name="CyanogenMod/android_device_motorola_spyder" path="device/motorola/spyder" remote="github" />
<project name="TheMuppets/proprietary_vendor_motorola" path="vendor/motorola" remote="github" revision="cm-12.0" />
</manifest>

and this is all, only make a new repo sync and if you see that the new projects are beeing downloaded your rom support this way, but if this don't work try the option below:

OPTION 2

First we need to know the codename of the device, Razr is “UMTS_SPYDER” and “SPYDER” depends if its GSM or CDMA. When we know this, we need to find the device in CyanogenMod github, to do this go here:

https://github.com/CyanogenMod

and put the name of your phone in the box that says “find a repository...”

for RAZR are these two:

(UMTS)

https://github.com/CyanogenMod/android_device_motorola_umts_spyder

(CDMA)

https://github.com/CyanogenMod/android_device_motorola_spyder

You will se something like that:

And you have to change the branch that you want to download by clicking in the button as you can see in the photo and select “cm-11.0”

When you change this then press on “download ZIP” at the right on the screen.

Okay, you will see that is a zip file, open it. When you open the file you will se a folder named like this(depending what you download this will change but this is an example).

“android_device_motorola_spyder-cm-11.0”

This name says in what folder you have to place tha files that are inside the folder(if some folder don’t exist make it).

REMEMBER TO WRITE ALL IN LOWERCASE

android=ROM folder; in my example is “DU”

device=this folder will be inside ROM folder, in my case “DU/device”

motorola=if this folder don’t exist make it

spyder=this folder will contain all the files that are into the zip inside “android_device_motorola_spyder-cm-11.0”

If you do all the steps well you will have something like this:

Inside this folder you will find some files, you you have to open one named “cm.dependencies”, inside this file you will find some lines like this:

[
{
"repository": "android_device_motorola_omap4-common",
"target_path": "device/motorola/omap4-common"
},
{
"repository": "android_kernel_motorola_omap4-common",
"target_path": "kernel/motorola/omap4-common"
}
]

This repositories you have to download and put in the folder that says “target_path”

To find it faster only add repository name at the end of this in firefox:

https://github.com/CyanogenMod/

in my case this will be like this:

https://github.com/CyanogenMod/android_device_motorola_omap4-common

and again you have to do the same like device(choose branch, and download as a ZIP) but you have to put the files into the correct folder, in this case I have to put it in DU/device/motorola/omap4-common.

And the same with Kernel:

https://github.com/CyanogenMod/android_kernel_motorola_omap4-common

But you have to put this in the correct folder, in my case: DU/kernel/motorola/omap4-common

Remember: If the folder didn’t exist make it and DON’T PUT THE FOLDER THAT COME INSIDE THE ZIP INSIDE THE FOLDER THAT YOU MAKE, put the files only, like this: DU/kernel/motorola/omap4-common ->>> in this folder you have to put all the files that came into the folder “android_kernel_motorola_omap4-common” inside the zip.

And finally you have to find your vendor folder, for this device "motorola", download from here and put this in the correct folder, in my case: DU/vendor/motorola(inside "motorola" you have to see other folder with the name of the devices, if you see this you are ready)

Thats all for now, you have all the files to make the rom to your device(IF YOU ARE BUILDING A CM BASED ROM).

Making NON-CM based ROMS​

If you want to build a non-CM based ROM you may have to change some files in your device folder, there are a lot of roms that need this changes so I can't explain all but in general you have to make changes(NOT IN OMAP4 FOLDERS) in "cm.mk", "AndroidProducts.mk", in this web you can see all the changes needed to build OMNIROM, not all the roms have this tutorials, so if you want ask me in this post(not PM me) I can help you, and I can modify and upload the file to be usefull for everyone. A little trick, all the roms that are non-CM based need changes in "cm.mk"(and maybe only with this change you can build the rom), you have to change the name of this file and edit this two lines:

"$(call inherit-product, vendor/cm/config/common_full_phone.mk)"

"PRODUCT_NAME := cm_spyder" or "PRODUCT_NAME := cm_umts_spyder"(obviusly depending wich device you open)

for DU for example you have to change like this:

"$(call inherit-product, vendor/du/config/common.mk)"(this is the same for all phones to build DU)

"PRODUCT_NAME := du_spyder" or "PRODUCT_NAME := du_umts_spyder"(depending wich device you open)

The first line is easy, for other roms only go to *Working folder*/vendor/*name of the rom*/config(in some roms is "configs") and here find the .mk file like "common" or "common_phone".

Or other way is to go to the github page and find a supported device and compare name of files and other things.

Then you have to create a new file named vendorsetup.sh in the device repo(doing this your device will appear to build later)

"add_lunch_combo *vendorROM*_*device*-userdebug"

OMNI ROM TUTORIAL TO PORT A DEVICE:

http://docs.omnirom.org/Porting_Omni_To_Your_Device

Make Changes on BASE to build​

PLEASE THIS IS FOR ADVANCED USERS, AND IF YOU WANT TO TRY FIRST OF ALL TRY TO BUILD ONCE WITHOUT THIS STEP, BECAUSE IF YOU MADE A BAD CHANGE YOUR ROM CAN BE UNUSABLE

Not all the devices have the same hardware posibilities, so some options are disabled, but once you build the ROM you can't enable it(some, not all), so you have to find the "config" file to make some changes and add functions. The config file that I'm refering you can find it in:

*Working folder*(in my case: DU)/framework/base/core/res/res/values/config.xml

and this file looks like this https://github.com/AOKP/frameworks_base/blob/kitkat/core/res/res/values/config.xml

Usually the lines that appears at the bottom are the variables from the rom, so I recomend to start from the bottom and then go up, PLEASE READ CAREFULLY ALL THE VARIABLES, don't pretend to enable funtions that the device can't support, and don't make any changes to variables that you don't know.

Some lines that appears in some config files that can be activated:

<integer name="config_deviceHardwareKeys">0</integer>

<bool name="config_enableWifiDisplay">false</bool>

<bool name="config_allowAllRotations">false</bool>

(THIS IS FOR EXPERTS BUT IF YOU WANT TO BE AN EXPERT I'LL TOLD YOU SOME TRICKS, IF YOU SEE THE LINES ABOVE AND YOU DON'T KNOW WHAT THIS MEANS FIRST READ IN THE FILE "CONFIG.XML" ABOVE THE VARIABLE AND YOU CAN KNOW MORE ABOUT IT, AND THEN PAY ATTENTION TO THIS:

Example:

<bool name="config_allowAllRotations">false</bool>

IN BLUE YOU CAN SEE THE NAME OF THE CHANGE, OBVIOUSLY THIS ENABLE ALL SCREEN ROTATIONS

AND IN GREEN YOU CAN SEE THE VALUE OF THIS VARIABLE(THIS VALUE CAN BE, A NUMBER OR "true" OR "false")

Commands for build​

If you read other guides you can see that appears a lot of commands to build a ROM, like breakfast, brunch, bacon, etc. I recomend to use "make otapackage" "mka bacon" or "time mka bacon"

Build​

The last step is build the ROM, to do this go to a terminal and go into your working folder, then initialize the repo(supposing that you have follow all the other steps and have a full repo sync) and put this command: "lunch", after this you will see all the devices supported to build, if you do all OK you will be able to see your device in the list, so only pick the number of your device and then in terminal will appear all the information about the device, finaly put "time mka bacon" or "make otapackage" and the terminal will start building the ZIP, the first command "time mka bacon" will build the rom using all the resources of your computer(so the build will be faster) and at the end you can se the time that it tooks.(depending if you are building in a VM or Native OS, and the specs of your computer it will take a time, in a VM for example my computer with 5GB of RAM and 3 cores(at 3.5GHz) can make one build in 6 hours, but in native OS with 6 cores and 16GB of RAM tooks 30 minutes).

ESPECIAL THANKS TO: [MENTION=2645562]sylentprofet[/MENTION] and nathanpfry.com (for the VM and OS)

Thanks for reading and sorry for my English.

Regards