[How to] Build your own Custom ROM!

Discussion in 'Galaxy Nexus Development' started by droseum20, Jan 13, 2012.

  1. droseum20
    Offline

    droseum20 Member

    Joined:
    Dec 24, 2010
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    6
    Before we start, just thought I would mention that "$" symbolizes a new line of code. Most of this information can be found on Building the System | Android Open Source

    1) Make sure you have Ubuntu 10.04 installed on your computer.

    2) Download the newest Android SDK for Linux here: http://developer.android.com/sdk/index.html

    3) Extract the insides into /<username>/android/sdk/ (create these directories)

    4) Open up a Terminal. Type:
    Code:
      $ cd android/sdk/tools 
    
      $ ./android 
    5) The Android SDK Manager will now pop up, make sure you have platform-tools and Android 4.0.3 checked. Then click Install '#' packages. Make sure to Accept All then select "Install". After a few minutes, it will finish and you can close the window.

    6) Go back into Terminal. Type:
    Code:
     $ cd
    
     $ sudo gedit .bashrc (make sure to give it your password) 
    7) A new window will pop-up with words you will not understand. Just make sure to scroll all the way to the bottom on a blank line and enter this: export PATH=${PATH}:~/android/sdk/platform-tools | Save and close the file.

    8) Now, time to install the Java 6 JDK. Open Terminal and type everything as follows:
    Code:
     $ sudo add-apt-repository "deb [U]http://archive.canonical.com[/U][URL="http://archive.canonical.com/"]/[/URL] lucid partner"
    
     $ sudo apt-get update
    
     $ sudo apt-get install sun-java6-jdk 
    9) This next code will install a lot of stuff that is critical to building Android. In Terminal copy and paste all of this and then simply hit enter:
    Code:
     $ sudo apt-get install git-core gnupg flex bison gperf build-essential \
    zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
    x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
    libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
    libxml2-utils xsltproc 
    10) For this next part, we will be configuring USB Access for your Android device. Open Terminal and type:
    Code:
     $ gksu nautilus (enter your password if asked) 
    11) This will open up File Browser with root abilities. Find the directory /etc/udev/rules.d/ | Create a new file called 51-android.rules and open it. It will be blank so copy and paste this:

    12) Still in the file, go to Search --> Replace. In "Search for" enter <username> (yes, include the <>). For "Replace with" enter your computer's username (the one you set up Ubuntu with). Click "Replace All" then save and exit the file.

    13) Open Terminal once again and type:
    Code:
     $ cd
    
     $ mkdir bin
    
     $ sudo gedit .bashrc 
    14) In the file that pops up, scroll to the bottom and enter the following on a blank line: export PATH=${PATH}:~/bin | Save and exit the file.

    15) Back in the Terminal window, type:
    Code:
     $ cd bin
    
     $ curl [URL]https://dl-ssl.google.com/dl/googlesource/git-repo/repo[/URL] > ~/bin/repo
    
     $ chmod a+x ~/bin/repo 
    16) You just installed the repo command into the bin folder we created recently. Now we need to use that command to access the android source code. Back in the same Terminal window, type:
    Code:
     $ cd ~/android
    
     $ mkdir source
    
     $ cd source
    
     $ repo init -u [URL]https://android.googlesource.com/platform/manifest[/URL] -b android-4.0.3_r1
      
    17) After running the last command, it should prompt you to type in your name and e-mail address. Please enter in your REAL Gmail's name and e-mail address.

    18) This next step will take possibly anywhere from 1-4 hours depending on your computer. In your Terminal window, type:
    Code:
     $ cd
    
     $ cd android/source
    
     $ repo sync    
    19) After the "repo sync" finishes, in the same Terminal window, you will want to verify the Git Tags by typing:
    Code:
     $ gpg --import (nothing will happen, that's okay)
    
    20) Copy and paste this into Terminal then click CTRL+D to enter:
    21) Go to Binaries for Nexus Phones and Flagship Devices - Google Support for Nexus Phones and Flagship Devices - Google Code and download the proper Nexus binaries, for Verizon you want to locate "Galaxy Nexus (CDMA/LTE)" and download the Graphics Component. After it finishes, open the imgtech-toro-iml74k.tgz and you will see a .sh file. Copy it and paste it into /android/source/. Do not put it in any other folders.

    22) Locate "extract-imgtec-toro.sh" in the directory just listed and double click it. Select "Run in Terminal". Keep clicking enter until you get to the end of the License. Then type I ACCEPT and enter. You just created a new folder inside of the Android source called "vendor".

    23) In your File Browser window, locate /android/source/device/samsung/toro. In "toro", you should see a file called extract-files.sh. Open this file with gedit. When it opens up, go to Search --> Replace. In "Search for" enter adb pull | In "Replace with" enter ./adb pull | Select "Replace All" then save and exit the file.

    24) Back in the File Browser, locate /android/sdk/platform-tools. You should see a file called "adb". Right click it, select copy, then back into /android/source/device/samsung/toro right click and paste "adb". At this point, you will want to plug in your device and make sure USB Debugging is enabled.

    25) Open a Terminal window and type:
    Code:
    $ cd ~/android/source/device/samsung/toro
    
    $ ./adb devices (it should now show your device is attached)
    
    $ ./extract-files.sh
    
    26) The last command we just entered extracted files such as CDMA/LTE radios from your phone and stuck them into the source. YOU CAN NOT BE ON A CUSTOM ROM OR THIS WILL NOT WORK. PLEASE BE ON ANDROID 4.0.2 OTA ROOTED (if you are on a custom ROM and don't feel like reverting to stock... please read the second post in this thread explaining a different way to do it)! We are now at the point where we can compile the final product.

    27) In Terminal, type:
    Code:
     $ cd ~/android/source
    
     $ lunch (it will now give you options, find "full_toro-userdebug" and type the number next to it and hit enter)
    
     $ make -j4 otapackage 
    28) The last command we just ran can take up to 5 hours, depending on the speed of your computer. If you have a quad-core, I recommend running make -j8 otapackage. It will take less time. After it completes, we will give it root access, and disable the automatic flashing back to stock recovery.

    29) Congratulations! You just compiled your first ROM. Now we must make last minute edits to ensure success. To see your final product, locate /android/source/out/target/product/toro. There should be one .zip file in the directory. Copy and paste it to your Desktop.

    30) We will now add root access. To do so, first go here to download Superuser.apk and the su binary I put together in a zip file: Galaxy Nexus Root by droseum20.zip | After downloading, open up the .zip until you see two folders, app and bin. Open "app" and you will see "Superuser.apk". Then, open your compiled ROM from your desktop. Go to System --> app. copy and paste Superuser.apk from one .zip to the other. Now go to System --> bin in both .zips. Take "su" and drag and drop it into the "bin" folder in your compiled ROM. Now it should have full root access.

    31) When compiling a ROM, it will automatically stick the stock recovery in there and we want to keep ClockworkMod, so we will do as follows. First. you will want to delete the recovery folder that is in your ROM. Next, from your ROM go to /META-INF/com/google/android/ and open updater-script. From here, not only we will delete flashing the OG recovery, we will also add some next text when any users flash our ROM.

    32) Now that you have the updater-script opened, Go to Search --> Search. Type in search for recovery. It will bring you to a line that says, "package_extract_dir("recovery", "/system")". Completely delete this line. If you want to give the users who flash your ROM some nice text while it is in the boring process of flashing, keep reading to 33. If you don't care and just want to finish this long process, skip to 34 (I advise reading 33 though).

    33) Still in the updater-script file, scroll all the way to the top. Make a new, blank, top line. Type ui_print("and then whatever you want. At the end of each line, you must include"); If you are confused, here is an example: ui_print("This is an example"); Now, if you want to make almost a design by using multiple lines, you can do that as well.

    34) After you save and exit the updater-script file, you may move on to this. Here I will show you how to either have Google Apps built into your ROM, or have Google Apps and your ROM flash separately. For this section, I give full credit to @Kejar31, the creator of GummyNex. Download his Google Apps from this ROM thread over at RootzWiki: [ROM][AOSP][4.0.3][CDMA] GummyNex 0.5.0 - 01/10/12 - RootzWiki After downloading, it will come out in a .zip package. Simply drag and drop it to your desktop.

    35) Now, you have Google Apps downloaded, but not baked inside of your ROM. To do this, we will open the GAPPS.zip file. Simply drag and drop the data folder from his GAPPS package into your ROM (not in any folder). Now, drag and drop the signed folder from one to the other. In the GAPPS pacakge, go to System, then app. Copy and paste all of them into the /System/app/ folder in your ROM. Then open the System --> etc from GAPPS and your /System/etc/. Open permissions on both, then copy and paste all the permissions from GAPPS into your ROM. Now copy and paste all the contents from /systesm/framework/ to your ROM. Open, /System/lib/ on both and once again copy and paste the contents from GAPPS into your ROM. Lastly, go to /System/Vendor/ and copy and paste the folder inside vendor (called pitpatt) into /System/vendor/ in your ROM.

    36) Okay, now you are ready to flash the ROM onto your phone to make sure all goes well. Simply transfer the full_toro-ota-eng.<username>.zip onto your phone however you usuaully would. Flash clockworkmod recovery if you already have not, wipe data/factory reset, wipe cache, then dalvik cache, install from zip on sd card, find the ROM and click "Yes" to install. Reboot your phone and make sure everything worked as expected! Run into a problem? Just read the second post or contact me via Google Talk (droseum20@gmail.com).
  2. droseum20
    Offline

    droseum20 Member

    Joined:
    Dec 24, 2010
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    6
    THE HELP POST!

    Having trouble with Google Apps? Maybe having duplicates of Gallery, Calender, or something else? Read #1. Superuser permissions not working? Read #2. What's up with the bootanimation? I miss the IceCreamSandwich one! Well, just read #3. On a custom ROM and don't want to revert back to stock? Easy, just read #4!

    #1: So this is rather simple. First, we will open the ROM and delete any multiples. Go to /System/App/ and delete CalendarGoogle.apk and GalleryGoogle.apk. No idea why they are doubled, but it happened to me too. Also, delete Tag.apk and just keep TagGoogle.apk. It is as easy at that.

    #2: Well, my su binary wouldn't work when installing the ROM, what do I do!? Well just download su.zip from here: http://download.clockworkmod.com/test/su.zip and flash it in ClockWorkMod Recovery. That's it.

    #3: If you REALLY REALLY REALLY hate the completely stock Android bootanimation, and want your original Galaxy Nexus animation back, you can do this. Simply take the bootanimation.zip from a ROM with the bootanimation you like and put it in /system/media. That is also where you find the ROM's bootanimation you want to take. Stick it in there and you are done.

    #4: Okay, since this one will be rather long compared to others, it will be formatted different in steps using abc...
    a) So your on step 25, and you don't want to go back to stock. Thanks to @koush, we can fix this.
    b) Open File Browser
    c) Find /android/source/vendor/samsung
    d) Open Terminal and cd to the location listed above
    e) Run "git clone https://github.com/koush/proprietary_vendor_samsung/tree/ics/toro.git toro"
    f) Now, move onto step 26. You are done.

    I will add more help as people get them. For now, these are the only fixes I think you will need.
  3. EmericanX
    Offline

    EmericanX Theme Developer Theme Developer

    Joined:
    Dec 1, 2011
    Messages:
    257
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Prince George, VA
    Need some help on root. I'd already compiled from source. No root. Ive tried to flash the su.zip which does flash su and superuser but I still get permission denied. I'm on an insecured boot.img as well... any ideas?

    Oh btw I did compile full toro user debug

    Sent from my Galaxy Nexus using Tapatalk
  4. droseum20
    Offline

    droseum20 Member

    Joined:
    Dec 24, 2010
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    6
    Delete Superuser.apk and su from bin. After that, check xbin to see if su is floating around in there. if so, delete it too. Then boot clockworkmod recovery and flash this: Superuser-3.0.7-efgh-signed.zip
  5. EmericanX
    Offline

    EmericanX Theme Developer Theme Developer

    Joined:
    Dec 1, 2011
    Messages:
    257
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Prince George, VA
    Failed to flash... error 0 . I'll take another wack at it when I've got my computer with me. I feel like im missing something in my source which is causing the issue... did you have to modify any of the source to gain root? Or just build and drop su and superuser in place?

    Sent from my Galaxy Nexus using Tapatalk
  6. droseum20
    Offline

    droseum20 Member

    Joined:
    Dec 24, 2010
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    6
    I did not modify source, but that may be a good idea. I have a ton of methods I can help you with. Can you contact me on GTalk?
  7. EmericanX
    Offline

    EmericanX Theme Developer Theme Developer

    Joined:
    Dec 1, 2011
    Messages:
    257
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Prince George, VA
    Pm sent..

    Sent from my Galaxy Nexus using Tapatalk
  8. bmkdroid
    Offline

    bmkdroid New Member

    Joined:
    Nov 19, 2011
    Messages:
    163
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pennsylvania
    Just found this, after being nearly done downloading the source. Perfect timing. Thanks a ton for the thread, going to let the downloads finish and work on this tomorrow!
  9. droseum20
    Offline

    droseum20 Member

    Joined:
    Dec 24, 2010
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    6
    no problem! happy to help.
  10. bmkdroid
    Offline

    bmkdroid New Member

    Joined:
    Nov 19, 2011
    Messages:
    163
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pennsylvania
    I am working on this step here as my device is already rooted and ROMd and would prefer not to have to go back to stock.

    I am on step E running git clone https://github.com/koush/proprietary_vendor_samsung/tree/ics/toro.git toro and I am receiving the following error:
    Initialized empty Git repository in /home/benkramer/android/vendor/samsung/toro/.git/
    fatal: https://github.com/koush/proprietary_vendor_samsung/tree/ics/toro.git/info/refs not found: did you run git update-server-info on the server?

    I assume this is an easy fix of cloning a different link, but I am not sure exactly how to find this link. I notice if I follow that link in a browser I see there is a directory named "toro" so I tried https://github.com/koush/proprietary_vendor_samsung/tree/toro/toro.git however that did not work either so I think perhaps the directories may have changed?

    Any help would be appreciated, as I do not have much experience using git and am not sure!

    UPDATE 1: Ok, so I ended up noticing at the top of the page when taking that link in a web browser it had the link "https://github.com/koush/proprietary_vendor_samsung.git" so I tried a git clone on that link in a separate folder to test it out. I believe I received within all of that, the toro folder I need. So, I am going to try continuin just copying and pasting that folder to the vendor/samsung where I believe it should be.

    UPDATE 2: That seemed to work just fine doing it the way I did, however, it would probably have been easier to get JUST the toro rather than his entire ICS tree (or whatever it is exactly that I got). Either way, compiled (only took about 1.5hrs on my machine!) and followed the last few steps with SU and GApps and am about to install it on my phone to test. SO EXCITED!
    Last edited: Jan 26, 2012
  11. skylordusa1
    Offline

    skylordusa1 New Member

    Joined:
    Aug 19, 2010
    Messages:
    204
    Likes Received:
    0
    Trophy Points:
    0



    Hey BMKDROID,

    Did this work out for you? I am getting the same error. Im curious if just grabbing the whole tree and moving the toro folder over to vendor/samsung worked fine. Let me know.
  12. trentreed
    Offline

    trentreed New Member

    Joined:
    Feb 14, 2011
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    0
    A Few Problems....

    Edit.....
    Last edited: May 8, 2012
  13. mjs1015
    Offline

    mjs1015 New Member

    Joined:
    Apr 3, 2011
    Messages:
    204
    Likes Received:
    0
    Trophy Points:
    0
    Will this root method work with 4.1.1?
  14. cowsquad
    Offline

    cowsquad New Member

    Joined:
    Mar 31, 2010
    Messages:
    276
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    beaverton, Oregon
    Awesome tutorial :)

    Sent from my Galaxy Nexus using Tapatalk 2
  15. bostonbassman78
    Offline

    bostonbassman78 New Member

    Joined:
    Apr 4, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    0
    kinda hoping someone still pays attenion to this i screwed up doing this part $ cd

    $ sudo gedit .bashrc (make sure to give it your password) i scrolled all the way down and i put that path in the wrong place and now i cant find it to correct it pls help im a noob at this

    Edit: figured it out but now I'm having issues with creating a folder for android/sdk

    Edit: figured it all out
    Last edited: Nov 8, 2012
Search tags for this page

how to build a custom rom

,
how to build a custom rom for galaxy nexus
,
how to build custom rom
,
how to create a custom rom
,
how to make a android rom
,

how to make a custom rom

,
how to make android rom
,
how to make custom rom
,
how to make custom rom for android
,
make android rom