View Poll Results: Was this thread helpful to you?
Yes 253 95.47%
No 12 4.53%
Voters: 265. You may not vote on this poll

Post Reply

Nexus 4 Guide-Unlock Bootloader, Root, Install Custom Recoveries & Custom ROMs/Kernel

6th May 2013, 01:15 PM   |  #1  
DJBhardwaj's Avatar
OP Recognized Contributor
Flag Delhi
Thanks Meter: 1,818
 
3,097 posts
Join Date:Joined: Apr 2011
Donate to Me
More

Hello people,

I recently got the honor to join this amazing Nexus 4 community. But, I’ve my history with Android since quite a time and I remember the early days of being a noob (newcomer). Though I was lucky enough because my fellow community members imparted me with sufficient knowledge to bring on to the basics of the Android custom world i.e Rooting the device, Installing Custom ROMs and Mods. Here I am to give out an helping hand and I want our new entries to feel the way I felt in the beginning; never ignored and forever helped. So if you’re a n00b and you’re reading this! Don’t you worry at all, I will take care and hit all the basics inside your head, step by step. I’ve already done this at the Nexus S section (look here).

I’m sure you’re more curious to get into the Android Development section and flash your desired ROM, I have felt that curiosity but I would advise you to stay calm and give these things some time and little bit of importance too, as then this knowledge will defend you from messing up your devices in the future.

Please do not be in a haste, understand the steps or information carefully and then only care to process it. Remember, haste makes waste (someone told me the very same and trust me, I could be the most experienced in making a practical example of this).


Terminology
  • What is Bootloader and Why do we need to Unlock?
    A bootloader is a boot initializing component which is generally locked by the device manufacturer to avoid any messing around with the OS. We need to unlock it for the same reason. Once unlocked it will allow us to change the boot sequence and modify the OS in accordance of our needs.
  • What is Rooting?
    It is a process of gaining root privileges over an Android subsystem. Rooting an Android device is easy in most cases. If you will to Install custom ROMs, kernels, other patches or addons to your Android device, rooting is what you will need. It can be achieved in two ways; either by manual method (using Recoveries) or by automatic method (using toolkit or software) . Here, I am going to follow the manual method.
  • ClockworkMod & TWRP, what are these?
    These are secondary recovery systems created by Koush (Koushik Dutta) & TeamWin, respectively. These add enormous features like wiping partitions, flashing flash-able .zip files like ROMs, kernels, patches etc to the stock AOSP recovery. Visit ClockworkMod website & TeamWin website for more detailed information.
  • What is a Custom ROM?
    These are the aftermarket Android firmware which are not official supported by the OEM (Original Equipment Manufacturer). They are made available to the Android public by Android developers and contributors all around the world. Custom ROMs are either built from Google’s source code i.e AOSP (Android Open Source Project) or are modified versions of the device manufacturer’s ROM (Stock ROMs or Factory ROMs) with additional tweaks and extend functions which are not delivered with the Stock ROMs. Some of the popular Custom ROMs include CyanogenMod (CM), Android Open Kang Project (AOKP), MIUI, Codename Android (CNA), Oxygen, ParanoidAndroid and many more.
  • What is Custom Kernel?
    A Kernel is a bridge between the applications and the actual data processing done at the hardware level, In simple words, it is the communication between the hardware and software of an Operating System. In Android world, Custom Kernels play a vital role since they provide the users with several features including changing CPU frequencies, modifying the boot sequence and boot scripts and other features too.
  • What are Google Apps (GApps)?
    The name speaks for itself. Gapps are Google apps for Android available in flash-able zip format. Most of these applications can now be found and updated via the Google Play Store.Some of the apps include the Google Play Store itself, Google Talk, Google Sync (for adding and synchronizing Google accounts), Google Backup Transport, Car Home, Gmail, Google Maps, YouTube, Google Search, Google Voice Search, Google Music, and Google Docs. In some Custom ROMs, the Google Apps are included. These are usually stock ROMs, smaller or less-common ROMs, or those from areas where intellectual property laws are less commonly obeyed. But many AOSP ROMs, most famously CyanogenMod and AOKP, do not include the Google Apps due to licensing issues. They are after all proprietary code owned by Google and not included in the Android Open Source Project.
Now, lets begin. The first thing we’ll be doing here, is to unlock the bootloader of your Nexus 4, followed by Installing a Custom Recovery, so that later on you can root and Install Custom ROMs/Kernels/Mods easily.

Prerequisites
  1. USB drivers configured properly. You may either use these amazing toolkits [WugFresh?s tookit | mskip’s toolkit] or do it manually using the Google USB drivers delivered with Android SDK (Do it the way you find it easy). Remember, USB drivers in this case doesn’t mean only the drivers to mount the device storage but rather the fastboot and adb drivers too.
  2. Compatible USB data cable.
  3. Android SDK configured (Follow this guide to setup Android SDK and thus it itself configures ADB and all other SDK components)
  4. USB Debugging enabled (Don’t know how? Take a look here)
  5. Backup Device Storage, Messages, Contacts, Calendars etc.
  6. 60% or above battery life (This is a recommendation to avoid any uncertain shutdowns during the mentioned process, it might cause issues)
  7. Fastboot binary (Put the file in <sdk_directory>/platform-tools)
Once you have filled in all the requirements, you shall follow further. If you have problem with setting up the prerequisites, please comment and get your issue resolved. Always remember, the more you ask, the more put up to your knowledge and the more you learn.



Unlock Bootloader
Don't want to lose your data after unlocking? Read this.
  1. Reboot your device into bootloader mode. Either manually, by powering off and then pressing Volume Down + Power buttons simultaneously or using the following command in CMD/Terminal.
    Code:
    adb reboot bootloader
  2. Connect the device to your PC using USB data cable.
  3. Open CMD/Terminal and confirm that the drivers are properly installed and the device is detected by entering the following command
    Code:
    fastboot devices
    The device ID shall be displayed as the output in your shell. If it is so then the response is positive but in case it shows something else, please make sure to properly install the drivers using a different method than that you used earlier.
  4. Type in the following in CMD/Terminal to initiate the unlocking process
    Code:
    fastboot oem unlock
  5. You will now be prompted with a warning message, use the volume keys to highlight Yes and select it using the power button. Then within a matter of seconds, your device shall be unlocked.
  6. To confirm that it is unlocked, look over to the text in front of Lock State and it should be unlocked.
  7. You’ve successfully unlocked.

What? Too easy? Yes, indeed. The following is as easy too.


Install Custom Recovery
We’ve 2 custom recoveries available yet for our Nexus 4 viz ClockworkMod and TWRP. ClockworkMod or CWM (in short) comes in 2 variants (Touch UI based & Non-Touch UI based). Below I have mentioned on how to flash each one of them using fastboot. For more info about these two recoveries, visit ClockworkMod and TeamWin websites.
  1. Reboot your device into bootloader mode. Either manually, by powering off and then pressing Volume Down + Power buttons simultaneously or using the following command in CMD/Terminal.
    Code:
    adb reboot bootloader
  2. Download the latest build of your desired recovery [CWM | TWRP]
  3. Place the downloaded recovery image (.img) file on your desktop.
  4. If in Windows, open CMD and cd it to the desktop using the following command
    Code:
    cd Desktop
  5. If in OS X or Linux, open terminal and cd it to the desktop using the following command
    Code:
    cd ~/Desktop
  6. To flash ClockworkMod Non-Touch, type in the following command:
    Code:
    fastboot flash recovery recovery-clockwork-x.x.x.x-mako.img
    Replace x.x.x.x with the recovery build no. that you downloaded.
  7. To flash ClockworkMod Touch, type in the following command:
    Code:
    fastboot flash recovery recovery-clockwork-touch-x.x.x.x-mako.img
    Replace x.x.x.x with the recovery build no. that you downloaded.
  8. To flash TWRP, type in the following command:
    Code:
    fastboot flash recovery openrecovery-twrp-x.x.x.x-mako.img
    Replace x.x.x.x with the recovery build no. that you downloaded.
  9. Once flashed, you will prompted on the CMD/Terminal itself.
  10. Now, either reboot your device by using volume keys to highlight Reboot and select using Power button or reboot into the recovery by selecting Recovery mode.
Voila! The next to follow is to root or directly flash a Custom ROM, which is already rooted.


Rooting
Not everyone and each one of us like Custom ROMs. Some users might prefer high stock stability over the features offered by Custom ROMs. and that’s completely normal. But, what if you have an App that requires Root privileges or may be, you need to access the System partition of your device to make certain modifications of your own? This is where the process of Rooting enters. Now when you already know what Rooting is, we shall head further and follow another set of very-simple instructions to root your Nexus 4.
  1. Download the latest SuperSU flash-able root package. [Chainfire's SuperSU Thread]
  2. Connect your device to the PC via USB cable.
  3. Transfer the downloaded file to a suitable location in the device.
  4. Do not disconnect the device.
  5. Open CMD/Terminal and type in the following command:
    Code:
    adb reboot recovery
  6. This will boot your device directly into recovery mode.
  7. You may now disconnect the device.
  8. If you are using CWM, tap on install zip from sdcard > choose zip from sdcard and select the CWM-SuperSU-v0.93.zip. When prompted select Yes to start the flashing process.
  9. If you are using TWRP, tap on Install and select the CWM-SuperSU-v0.93.zip. Slide the circular button to start the flashing process.
  10. When the flashing process has finished, select reboot system now (In CWM) or Reboot > System (In TWRP) to reboot your device.
Congrats! You have successfully rooted your device. Go ahead and use any App that requires Root permissions.


Installing Custom ROM
Its simple, very much simple. All you got to do, is to choose a Custom ROM and simply flash it via your custom recovery.
  1. The very first step is to choose a Custom ROM that fits all your needs and serves you with your desires. When chosen, download the ROM file (flashable zip).
    NOTE: Every ROM here at this section is worth and is a result of hardwork of developers/team. Please do not criticize any ROM for any reason. Maintain the forum spirit by encouraging people.
  2. Download the suitable GApps package corresponding to the Android version of your ROM [Link]
  3. In case, the developer has provided specific modified GApps package, download that. Then there is no need to download the GApps package from step #2
  4. Connect your device to the PC via USB data cable.
  5. Transfer the ROM & GApps zip to the device. Its is recommended to put the files in the root of your device storage for convenience.
  6. Disconnect the device,
  7. Power off. Press the Volume Down and Power keys together to boot into the Bootloader mode.
  8. Use the volume keys to highlight Recovery mode and select it using the Power button. Your device will then boot itself into Recovery mode.
  9. Flash using CWM
    wipe data/factory reset
    wipe cache partition
    Go to "mounts and storage" > "format /system" "format /boot"
    Go to "install zip from sdcard" > "choose zip from sdcard" > select your ROM .zip file that you placed in step #6. Flash it.
    Gapps are the next to be flashed just after flashing the ROM. So, flash Gapps following the same way as the ROM. further if your are provided any add-on in a flash able zip format you can flash it the same way after flashing the ROM and GApps successfully.
    Once everything has flashed successfully, select "reboot system now".
  10. Flash using TWRP
    Go to "Wipe" > "Advanced" and "Factory Reset".
    Go to "Install" > choose the ROM .zip file and flash it.
    Gapps are the next to be flashed just after flashing the ROM. So, flash Gapps following the same way as the ROM. further if your are provided any add-on in a flash able zip format you can flash it the same way after flashing the ROM and Gapps successfully.
    When flashed, go to "Reboot" > "System".

Your phone will now boot into the custom ROM.


Install Custom Kernel
People often prefer using a Custom Kernel rather than that already delivered with the ROM. For the available kernels, head over to Nexus 4 Original Development section. Every kernel is unique in its own terms, so make a choice. If you’re not satisfied with the combination, move on and try some other kernel.
  1. Choose a custom Kernel and download its flashable zip.
  2. Connect your device to the PC via USB data cable.
  3. Transfer the Kernel flashable zip to the device. Its is recommended to put the file in the root of your device storage for convenience.
  4. Disconnect the device.
  5. Power off. Press the Volume Down and Power keys together to boot into the Bootloader mode.
  6. While on the Bootloader screen, use the volume keys to highlight Recovery mode and select it using the Power button. Your device will then boot itself into Recovery mode.
  7. Flash using CWM
    - Select "wipe cache partition"
    - Tap on "advanced" and select "Wipe Dalvik Cache"
    - Tap on "install zip from sdcard" > "choose zip from sdcard". Now browse and select the kernel zip package that you placed in your storage root during step #3.
    - Select "Yes" when prompted to start the flashing process.
    - Your Kernel will now flash to your OS and replace your current kernel.
    - When it has successfully flashed, select "reboot system now".
  8. Flash using TWRP
    - Tap "Wipe" > "Advanced Wipe" and tick "Dalvik Cache" & "Cache".
    - Slide the button at the end of the screen to start the wiping process.
    - Tap on "Install" > now browse and select the kernel zip package that you placed in your storage root during step #3.
    - Slide the button at the end of the screen to start the flashing process.
    - Your Kernel will now flash to your OS and replace your current kernel.
    - When it has successfully flashed, tap to "Reboot" and select "System".

You now have Custom Kernel installed on your Nexus 4.
NOTE: Before choosing and flashing any Custom Kernel, make sure its compatible with your present Android version.

I hope this guide has helped you. I would be proud, if anyone has received any kind of fruitful knowledge/guidance from this thread.
In case you get stuck anywhere, feel free to comment and ask. Or if I've missed something or may if I am wrong somewhere, please do let me know.

Good Luck with going custom on your Nexus 4
Last edited by DJBhardwaj; 20th May 2013 at 02:52 PM. Reason: Amended the SuperSU file links
The Following 147 Users Say Thank You to DJBhardwaj For This Useful Post: [ View ]
8th May 2013, 01:07 PM   |  #2  
Member
Thanks Meter: 5
 
87 posts
Join Date:Joined: Apr 2013
Hey awesome tutorial....nice and detailed.....plz can u make a tutorial using the automatic method(toolkit)

Thanks
The Following User Says Thank You to dsjd For This Useful Post: [ View ]
8th May 2013, 01:26 PM   |  #3  
spaceman860's Avatar
Senior Member
Thanks Meter: 1,443
 
1,978 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by dsjd

Hey awesome tutorial....nice and detailed.....plz can u make a tutorial using the automatic method(toolkit)

Thanks

You won't learn anything using a toolkit and if something goes wrong you won't know how to fix it. XDA is a place to learn

Sent from my Nexus 4
The Following 4 Users Say Thank You to spaceman860 For This Useful Post: [ View ]
8th May 2013, 01:34 PM   |  #4  
Member
Thanks Meter: 5
 
87 posts
Join Date:Joined: Apr 2013
Quote:
Originally Posted by spaceman860

You won't learn anything using a toolkit and if something goes wrong you won't know how to fix it. XDA is a place to learn

Sent from my Nexus 4

So its safer to do it manually ?
8th May 2013, 01:46 PM   |  #5  
DJBhardwaj's Avatar
OP Recognized Contributor
Flag Delhi
Thanks Meter: 1,818
 
3,097 posts
Join Date:Joined: Apr 2011
Donate to Me
More
Quote:
Originally Posted by dsjd

So its safer to do it manually ?

Everything is safe for a Nexus. But, this guide will provide you with suitable knowledge.
8th May 2013, 01:46 PM   |  #6  
spaceman860's Avatar
Senior Member
Thanks Meter: 1,443
 
1,978 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by dsjd

So its safer to do it manually ?

Yes and if you need help just ask

http://forum.xda-developers.com/show....php?t=1469909

The Dangers of Tool Kits and One Click Root Methods + Mini Rant

Sent from my Nexus 4
Last edited by spaceman860; 8th May 2013 at 01:49 PM.
The Following 3 Users Say Thank You to spaceman860 For This Useful Post: [ View ]
8th May 2013, 02:13 PM   |  #7  
Chromium's Avatar
Recognized Contributor
Flag Toronto
Thanks Meter: 5,983
 
4,400 posts
Join Date:Joined: Oct 2012
Donate to Me
More
Nice guide. I have one question.
In this guide: http://forum.xda-developers.com/show....php?t=2018179 it mentions that after flashing the custom recovery, the stock recovery may restore itself and overwrite the custom one. Is it necessary to do anything to stop this from happening ?

Sent from my HTC Desire using xda app-developers app
8th May 2013, 02:46 PM   |  #8  
Member
Thanks Meter: 5
 
87 posts
Join Date:Joined: Apr 2013
Can u plz giv little more detailed steps on installing drivers?
8th May 2013, 03:43 PM   |  #9  
spaceman860's Avatar
Senior Member
Thanks Meter: 1,443
 
1,978 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by chromium96

Nice guide. I have one question.
In this guide: http://forum.xda-developers.com/show....php?t=2018179 it mentions that after flashing the custom recovery, the stock recovery may restore itself and overwrite the custom one. Is it necessary to do anything to stop this from happening ?

Sent from my HTC Desire using xda app-developers app

The newest versions of custom recovery prevents that from happening

Sent from my Nexus 4
9th May 2013, 04:16 AM   |  #10  
Member
Thanks Meter: 5
 
87 posts
Join Date:Joined: Apr 2013
Hey ...i just wanted to know if there are any safety-nets that i can use ...like backups or something?

The Following User Says Thank You to dsjd For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
google nexus 4, lg nexus 4, root nexus 4, unlock bootloader nexus 4
Previous Thread Next Thread
Thread Tools
Display Modes


Top Threads in Nexus 4 General by ThreadRank