[GUIDE]How To Build A ROM Using A Phone

Search This thread

Saurabhcr7

Senior Member
Sep 5, 2015
129
164
25
New Delhi
I am writing this tutorial together in an attempt to help beginners which are trying to build a ROM from source for the first time.I faced many problems when I started building roms, so I thought it will be better to help someone who is trying the same thing.I have tried to make this guide easy to understand.Please feel free to PM if you have any doubts!!
And if you built a rom by following this guide then please press the thanks button, it will motivate me.


For Whom This Guide Is For

1. Who do not have a PC which meets required requiements for building a rom
2. Who cannot download the sources which might be upto 10GB
3. Who is building a rom for the first time


Prerequisites
1. Android Phone
2. A decent internet connection
3. A debit/credit card
4. Brain:p

Contents
1. Making a Google Cloud Account
2. Setting up the VM (Virtual Machine) on your phone
3. Setting up the build environment
4. Initializing and syncing the repo
5. Cloning the device,kernel and vendor tree
6. Building the rom
7. Uploading the ROM in Google Drive

1. Making A Google Cloud Account

NOTE:You will need a credit/debit card for making an account and it is free to use Google Cloud for one year only.

STEP 1:Open Google Cloud from here.
STEP 2:Click on Free Trial
http%3A%2F%2Fi.imgur.com%2Ftz27LHx.png

STEP 3:Login with your Google account username and password.
http%3A%2F%2Fi.imgur.com%2FmgEf2dv.png

http%3A%2F%2Fi.imgur.com%2F9qOMBwV.png



2. Setting up the VM (Virtual Machine) on your phone

STEP 1:Download Juice SSH app from here.
STEP 2:Open Juice SSH app and click on "Connections".
STEP 3:Navigate to "Identities" and create a new identity by pressing the "+" button.
STEP 4:Input the "Nickname","Username" (You can enter your name also in both places) and then click on "Private Key"(Set (Optional) button). Navigate to "Generate" and press OK and click on the tick icon.
STEP 5:Now long press the identity you just created and click on "Export Public Key" and click on ES Note Editor or Keep (You need any one of them) and replace the "JuiceSSH" written at the end with your username you entered in the identity and now copy the whole text.
STEP 6:Open Google Cloud and navigate to Computer Engine->Metadata->SSH Keys. Click on edit and then add item.Paste the text you just copied and save it.
STEP 7:Navigate to Computer Engine->VM Instances. Click on "Create Instance".Enter the name(Any name).Select Machine Type as "4vCPU". Select Boot Disk as "Ubuntu 16.04 LTS" and set the size to 1000GB.Tick both "Allow HTTP traffic" and
"Allow HTTPS traffic" and click on create.
STEP 8:Now it will take a minute.After it is created copy the External IP.
STEP 9:Now open Juice SSH app and navigate to "Connections" and create a connection by clicking on the "+" icon.Input the nickcname you entered while creating the identity.Paste the External IP in the "Address" column and click on the tick icon.
STEP 10:Now click on the connection you just created. This will open the terminal on which you need to work.


3. Setting up the build environment
NOTE:You just need to copy and paste the below codes one by one.

1. sudo apt update
2. sudo apt upgrade
3. sudo apt-get install git-core
4. git clone https://github.com/akhilnarang/scripts
5. cd scripts
6. bash setup/ubuntu1604linuxmint18.sh
7. mkdir -p ~/bin
8. mkdir -p ~/android/lineage (Replace lineage with your rom name or you can also use lineage for any rom for easy to understand))
9. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
10. chmod a+x ~/bin/repo
11. cd ~/android/lineage

4. Initializing and syncing the repo
1. repo init -u https://github.com/LineageOS/android.git -b cm-14.1

NOTE:Here I am compiling lineage os 14.1 therefore I am using it's repo initializing command.
You can find repo initialization command for your rom by the following method:
(i) Google search "rom_name github" (Replace rom_name with your rom name)
(ii) Open the rom github in dextop mode.(Use Google Chrome)
(iii)Click on the "manifest" or "android_manifest"
(iv) Select the branch which you want to build and copy the repo initialization command given at bottom.

Some repo initialization commands:
(i). repo init -u https://github.com/ResurrectionRemix/platform_manifest.git -b nougat
(ii). repo init -u https://github.com/AICP/platform_manifest.git -b n7.1
(iii). repo init -u git://github.com/CandyRoms/candy.git -b c7.1.2
(iv). repo init -u https://github.com/BlissRoms/platform_manifest.git -b n7.1


2. repo sync -j8

Go get a coffee till the source is syncinc. It will take time depending on your internet speed.

5. Cloning the device,kernel and vendor tree

1. git clone device_tree_link_here -b branch_name_here device/manufacturer_name_here/device_name_here
Eg: git clone https://github.com/LineageOS/android_device_xiaomi_mido.git -b cm-14.1 device/xiaomi/mido
2. git clone kernel_tree_link_here -b branch_name_here kernel/manufacturer_name_here/chipset_name_here
Eg: git clone https://github.com/LineageOS/android_kernel_xiaomi_msm8953.git -b cm-14.1 kernel/xiaomi/msm8953
3. git clone vendor_tree_link_here vendor/manufacturer_name_here
Eg: git clone https://github.com/TheMuppets/proprietary_vendor_xiaomi.git vendor/xiaomi

NOTE:1.To find device tree link follow the following steps:
(i)Google search "Device_name device tree github"
(ii)Select the branch and copy the device tree link.

2.To find the kernel tree link follow the below steps:
(i)Google search "lineage os github".
(ii)Input your chipset name in the search box and select the repository for your device.
(iii)Copy the link.

3.To find the vendor tree link follow the below steps:
(i)Google search "The Muppets Github".
(ii)Find the repository for your device and copy the link.

If you can't find any tree with the above methods, then simply google search that tree for your device!!!!


6. Building the rom

1. export USE_CCACHE=1
2. prebuilts/misc/linux-x86/ccache/ccache -M 50G
3. export CCACHE_COMPRESS=1
4. . build/envsetup.sh
5. brunch device_name_here
or
5. make bacon -j8

Now it will take approx 7-8 hrs or more depending upon your internet speed.Go get a sleep till then.


7. Uploading the ROM in Google Drive


1. cd ~
2. wget https://docs.google.com/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&export=download
3. mv uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive
4. chmod +x gdrive
5. sudo install gdrive /usr/local/bin/gdrive
6. gdrive list
7. cd out/target/product
8. ls
Check your ROM name.
9. gdrive upload same_rom_name_here
Now it will show a link. Click on it and copy the code and paste it in the terminal.
Now your rom will start uploading in your Google Drive.

Congratulations You Built Your First ROM!!

Don't forget to press the thanks button

Donate Me
If I helped you a little bit then buy me coffee
Here
Or

Credits
SaurabhCR7(Me:fingers-crossed:)
@nitin.chobhe (For his images and guide for google cloud)
Akhil Narang(For his Scripts)
Google
XDA
 
Last edited:

Saurabhcr7

Senior Member
Sep 5, 2015
129
164
25
New Delhi
Why i get this? I dont set any password
You are performing this step wrongly.

STEP 5:Now long press the identity you just created and click on "Export Public Key" and click on ES Note Editor or Keep (You need any one of them) and replace the "JuiceSSH" written at the end with your username you entered in the identity and now copy the whole text.
 

Diki Saputra

Senior Member
Dec 13, 2016
100
19
You are performing this step wrongly.

STEP 5:Now long press the identity you just created and click on "Export Public Key" and click on ES Note Editor or Keep (You need any one of them) and replace the "JuiceSSH" written at the end with your username you entered in the identity and now copy the whole text.

Ok,i try make du 8.1.0,i cant see source at du github
 

alnasnasu

Member
Feb 14, 2017
37
6
Hey bro, in other forums it is given that it consumes a lot of data to download repo files(or something like that). By doing this in cloud won't it take data to do that??? If it doesn't make sense then sorry... I am a real noob
 

alnasnasu

Member
Feb 14, 2017
37
6
So downloading directly to cloud means that google is downloading the data to cloud by our command and without our intervention
 

alnasnasu

Member
Feb 14, 2017
37
6
while downloading repo, if i turn off the internet connection it will still dowload in the cloud, Right???
 

raj_jdja

Senior Member
Dec 17, 2013
184
654
Mumbai, Thane
What if I've to edit my device tree? How can i edit it if files are virtual

What if I've to edit my device tree? How can i edit it if files are virtual??
 

Top Liked Posts

  • There are no posts matching your filters.
  • 50
    I am writing this tutorial together in an attempt to help beginners which are trying to build a ROM from source for the first time.I faced many problems when I started building roms, so I thought it will be better to help someone who is trying the same thing.I have tried to make this guide easy to understand.Please feel free to PM if you have any doubts!!
    And if you built a rom by following this guide then please press the thanks button, it will motivate me.


    For Whom This Guide Is For

    1. Who do not have a PC which meets required requiements for building a rom
    2. Who cannot download the sources which might be upto 10GB
    3. Who is building a rom for the first time


    Prerequisites
    1. Android Phone
    2. A decent internet connection
    3. A debit/credit card
    4. Brain:p

    Contents
    1. Making a Google Cloud Account
    2. Setting up the VM (Virtual Machine) on your phone
    3. Setting up the build environment
    4. Initializing and syncing the repo
    5. Cloning the device,kernel and vendor tree
    6. Building the rom
    7. Uploading the ROM in Google Drive

    1. Making A Google Cloud Account

    NOTE:You will need a credit/debit card for making an account and it is free to use Google Cloud for one year only.

    STEP 1:Open Google Cloud from here.
    STEP 2:Click on Free Trial
    http%3A%2F%2Fi.imgur.com%2Ftz27LHx.png

    STEP 3:Login with your Google account username and password.
    http%3A%2F%2Fi.imgur.com%2FmgEf2dv.png

    http%3A%2F%2Fi.imgur.com%2F9qOMBwV.png



    2. Setting up the VM (Virtual Machine) on your phone

    STEP 1:Download Juice SSH app from here.
    STEP 2:Open Juice SSH app and click on "Connections".
    STEP 3:Navigate to "Identities" and create a new identity by pressing the "+" button.
    STEP 4:Input the "Nickname","Username" (You can enter your name also in both places) and then click on "Private Key"(Set (Optional) button). Navigate to "Generate" and press OK and click on the tick icon.
    STEP 5:Now long press the identity you just created and click on "Export Public Key" and click on ES Note Editor or Keep (You need any one of them) and replace the "JuiceSSH" written at the end with your username you entered in the identity and now copy the whole text.
    STEP 6:Open Google Cloud and navigate to Computer Engine->Metadata->SSH Keys. Click on edit and then add item.Paste the text you just copied and save it.
    STEP 7:Navigate to Computer Engine->VM Instances. Click on "Create Instance".Enter the name(Any name).Select Machine Type as "4vCPU". Select Boot Disk as "Ubuntu 16.04 LTS" and set the size to 1000GB.Tick both "Allow HTTP traffic" and
    "Allow HTTPS traffic" and click on create.
    STEP 8:Now it will take a minute.After it is created copy the External IP.
    STEP 9:Now open Juice SSH app and navigate to "Connections" and create a connection by clicking on the "+" icon.Input the nickcname you entered while creating the identity.Paste the External IP in the "Address" column and click on the tick icon.
    STEP 10:Now click on the connection you just created. This will open the terminal on which you need to work.


    3. Setting up the build environment
    NOTE:You just need to copy and paste the below codes one by one.

    1. sudo apt update
    2. sudo apt upgrade
    3. sudo apt-get install git-core
    4. git clone https://github.com/akhilnarang/scripts
    5. cd scripts
    6. bash setup/ubuntu1604linuxmint18.sh
    7. mkdir -p ~/bin
    8. mkdir -p ~/android/lineage (Replace lineage with your rom name or you can also use lineage for any rom for easy to understand))
    9. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    10. chmod a+x ~/bin/repo
    11. cd ~/android/lineage

    4. Initializing and syncing the repo
    1. repo init -u https://github.com/LineageOS/android.git -b cm-14.1

    NOTE:Here I am compiling lineage os 14.1 therefore I am using it's repo initializing command.
    You can find repo initialization command for your rom by the following method:
    (i) Google search "rom_name github" (Replace rom_name with your rom name)
    (ii) Open the rom github in dextop mode.(Use Google Chrome)
    (iii)Click on the "manifest" or "android_manifest"
    (iv) Select the branch which you want to build and copy the repo initialization command given at bottom.

    Some repo initialization commands:
    (i). repo init -u https://github.com/ResurrectionRemix/platform_manifest.git -b nougat
    (ii). repo init -u https://github.com/AICP/platform_manifest.git -b n7.1
    (iii). repo init -u git://github.com/CandyRoms/candy.git -b c7.1.2
    (iv). repo init -u https://github.com/BlissRoms/platform_manifest.git -b n7.1


    2. repo sync -j8

    Go get a coffee till the source is syncinc. It will take time depending on your internet speed.

    5. Cloning the device,kernel and vendor tree

    1. git clone device_tree_link_here -b branch_name_here device/manufacturer_name_here/device_name_here
    Eg: git clone https://github.com/LineageOS/android_device_xiaomi_mido.git -b cm-14.1 device/xiaomi/mido
    2. git clone kernel_tree_link_here -b branch_name_here kernel/manufacturer_name_here/chipset_name_here
    Eg: git clone https://github.com/LineageOS/android_kernel_xiaomi_msm8953.git -b cm-14.1 kernel/xiaomi/msm8953
    3. git clone vendor_tree_link_here vendor/manufacturer_name_here
    Eg: git clone https://github.com/TheMuppets/proprietary_vendor_xiaomi.git vendor/xiaomi

    NOTE:1.To find device tree link follow the following steps:
    (i)Google search "Device_name device tree github"
    (ii)Select the branch and copy the device tree link.

    2.To find the kernel tree link follow the below steps:
    (i)Google search "lineage os github".
    (ii)Input your chipset name in the search box and select the repository for your device.
    (iii)Copy the link.

    3.To find the vendor tree link follow the below steps:
    (i)Google search "The Muppets Github".
    (ii)Find the repository for your device and copy the link.

    If you can't find any tree with the above methods, then simply google search that tree for your device!!!!


    6. Building the rom

    1. export USE_CCACHE=1
    2. prebuilts/misc/linux-x86/ccache/ccache -M 50G
    3. export CCACHE_COMPRESS=1
    4. . build/envsetup.sh
    5. brunch device_name_here
    or
    5. make bacon -j8

    Now it will take approx 7-8 hrs or more depending upon your internet speed.Go get a sleep till then.


    7. Uploading the ROM in Google Drive


    1. cd ~
    2. wget https://docs.google.com/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&export=download
    3. mv uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive
    4. chmod +x gdrive
    5. sudo install gdrive /usr/local/bin/gdrive
    6. gdrive list
    7. cd out/target/product
    8. ls
    Check your ROM name.
    9. gdrive upload same_rom_name_here
    Now it will show a link. Click on it and copy the code and paste it in the terminal.
    Now your rom will start uploading in your Google Drive.

    Congratulations You Built Your First ROM!!

    Don't forget to press the thanks button

    Donate Me
    If I helped you a little bit then buy me coffee
    Here
    Or

    Credits
    SaurabhCR7(Me:fingers-crossed:)
    @nitin.chobhe (For his images and guide for google cloud)
    Akhil Narang(For his Scripts)
    Google
    XDA
    3
    Give credit in OP to @nitin.chobhe for the first part of your guide.
    P.S: Thanks for the efforts in making this guide.
    1
    I'm trying to build DotOS for cheeseburger. Which device tree should I use? It must be one created by DotOS?

    No it is not necessary. Actually the device tree is same everywhere, different roms just fork them from lineage os device tree. BTW here is the link for your device tree:

    https://github.com/LineageOS/android_device_oneplus_cheeseburger
    1
    Getting this error:

    curl: (22) The requested URL returned error: 404 Not Found
    Server does not provide clone.bundle; ignoring.
    fatal: Couldn't find remote ref refs/heads/dot-o

    What am I doing wrong?

    Use this

    git clone https://github.com/LineageOS/android_device_oneplus_cheeseburger.git -b lineage-15.1 device/oneplus/cheeseburger
    1
    Hey bro when started the rom building command after 65% juice ssh closed the connection and when I restarted the connection all my progress was lost
    Before building always do

    tmux

    Then u can disconnect process will continue just dont close server

    To reopen progress

    tmux attach -tx

    Here x is session number
    Like
    tmux attach -t0