[GUIDE] Nexus 4 - Unlock & Root

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Nexus 4 Unlock and Root Guide

Let's just get right into this :)
[WARN]Warning: Unlocking the bootloader will wipe your entire device, including the internal sdcard. You will lose everything that you do not backup to your computer before you begin. Keep that in mind before you proceed.
I am not responsible for anything that happens to your device. Unlocking and rooting always has the possibility of bringing about softbricks, voided warranties, global thermonuclear war, and soiled undergarments. You and you alone assume all risk if you choose to proceed. :)[/WARN]
Are we clear? Good. The instructions in the following tabs are not difficult, but please, please, PLEASE read them fully and carefully. It is equally important for you to understand the process in addition to getting it right. Ready to roll...

Intro
A few items you will need before we begin..
1. ADB and fastboot files If you have installed the Android SDK these will be located in your Android SDK /platform-tools directory, or wherever you downloaded them to before. Make sure you know where they are. If you need to grab them again, I totally stole these from smarter people than me (namely PaulOBrien) and just took out stuff we don't need, and renamed it to avoid confusion for you guys. Download from here: https://dl.dropbox.com/u/47300967/nexus4-adb-fastboot.zip
Stick that on your desktop and unzip it so you will have a folder called nexus4-adb-fastboot on the desktop containing the files.

2. Drivers If you are on a Windows system (linux and mac need not bother with these): Universal Naked Driver 0.72.zip
Warning: Uninstall any previous driver package's you may have installed and also manually remove drivers by attaching your phone and going to Windows device manager and right click the entry for your phone and select "Uninstall" on the next prompt make sure to select "Delete the driver software for this device" then hit OK and reboot before installing these drivers
HUGE thanks to 1wayjonny at xda for these drivers and instructions!!
[TIP]*Windows 8 users: You probably will need to disable Driver Signature Enforcement. Instructions:
From the Metro Start Screen, open Settings (move your mouse to the bottom-right-corner of the screen and wait for the pop-out bar to appear, then click the Gear icon).
Click ?More PC Settings?.
Click ?General?.
Scroll down, and click ?Restart now? under ?Advanced startup?.
Wait a bit.
Click ?Troubleshoot?.
Click ?Advanced Options?
Click ?Windows Startup Settings?
Click Restart.[/TIP]

3. TWRP Recovery This will be our custom recovery that we use to gain root (and later, flash ROMs and such if you choose). It is a fast, smooth, intuitive and open-source recovery. Download directly here: Techerrata Downloads - Downloading openrecovery-twrp-2.4.1.0-mako.img
It's also good to check TWRP's site and make sure you're getting the latest version, Link provided here: TeamWin Projects - TWRP 2.4 - Nexus 4 | TeamWin
Rename the file to recovery.img and place it inside the folder that contains your fastboot and adb files.
Credit Team Win for their awesome efforts on TWRP!

If you really prefer CWM Recovery, you may use that as well, but be advised I will be using TWRP on my device and won't be able to advise as well if anything goes wrong with CWM. Download from here:http://download2.clockworkmod.com/recoveries/recovery-clockwork-touch-6.0.2.3-mako.img
Rename the file to recovery.img and place it inside the folder that contains your fastboot and adb files.
Credit as always to Koush!

4. Superuser.zip This will grant us root access after we flash it in recovery. Download here: http://download.clockworkmod.com/superuser/superuser.zip
Place this .zip file inside the folder that contains your fastboot and adb files.
Credit goes to Koush!
Setup and Files

What appears as commands in the following tabs are GENERAL INSTRUCTIONS TO UNLOCK, FLASH RECOVERY, AND ROOT. Make sure you know how to do it for your computer/setup and that ADB and fastboot is set up on your computer. Know the exact folder containing the fastboot files you will be using.

[NOTE]Throughout these instructions I will be entering our commands in the format:
Code:
fastboot ? ? ?
However, you must remember to modify just the beginning part to reference the appropriate file for your system.
For Windows this should look like:
Code:
fastboot-windows ? ? ?
For Linux (note that sudo may be required before entering fastboot commands):
Code:
sudo fastboot-linux ? ? ?
For Mac (note that ./ is required before entering the commands on a Mac):
Code:
./fastboot-mac ? ? ?
[/NOTE]

Please make sure you understand that before moving forward..

Re: PC/MAC/LINUX
Are you still with me? Great... let's get started!

As a quick intro to Unlocking it.. why not watch AC's Phil Nickinson walk you through it!

[INFO]1. Power off your Nexus 4, and reboot it into fastboot mode by holding the volume down button and power. You'll see the familiar green robot, and the word "Start" at the top of the screen. Note the last line will read "Lock state - locked"

2. Open a command prompt inside the folder we have our adb and fastboot files in. On Windows this can be done by holding shift as you right-click in the folder, then select "Open command window here". On Mac or on a Linux system you want to open a terminal/command prompt and navigate to that folder using "cd" or "change directory" commands. For example, if you grabbed the zip I posted earlier and extracted it on your desktop, your folder is called "nexus4-adb-fastboot" on your desktop, and you would enter:
Code:
cd desktop
cd nexus4-adb-fastboot
Now your command prompt is ready in the correct directory for all of the following commands.

3. Plug your phone into a full speed primary USB port on your computer. If you're using Windows, you'll see the pop-up about drivers being installed and initialized.

4. Let's make sure fastboot is recognizing your device. Type this command and hit Enter:
Code:
fastboot devices
You should see "List of attached devices" Followed by a string of numbers. If you do not see this, you do not have your drivers installed correctly! You may need to remove them and try just reinstalling from the Setup tab earlier. If you got the expected response, continue..

5. Now the simple, magical code which will unlock your bootloader. In your command prompt type the following and hit Enter:
Code:
fastboot oem unlock
Look at your phone screen. You should see a dialog warning that your device will be wiped, etc. Use the Up Volume key to highlight Yes and hit the Power key to select it. You will return to the fastboot screen and the bottom line will read "Lock state - unlocked"

6. There is no step 6... You have unlocked your bootloader successfully! If you ever wish to re-lock the bootloader, just follow along just like we did here and instead enter the command:
Code:
fastboot oem lock

Alright.. that was easy wasn't it? Now let's root it![/INFO]

Unlocking The Bootloader



[INFO]1. Boot your phone up by pressing the Power button. Bypass / skip through the activation screens. Once booted, and still connected to your computer, drag and drop the superuser.zip file we downloaded earlier on to the root of your sdcard - meaning just the base of your internal storage, not inside any folders. Now unplug and power down the phone, boot into the bootloader again just like earlier, and plug it back in.
**More astute/advanced users may want to skip this step and just push this file using adb once they get into recovery. You can do that if you like, but I've found that can work inconsistently, so for now I'm going to have people just do it this way :)

2. This command will boot you into CWM, it will not flash it permanently. Type it in and press Enter.
Code:
fastboot boot recovery.img

3. Tap "Install zip from sdcard" and locate the superuser.zip file, and select it and tap Yes to install. You have now root! Go back and select the option to Reboot System.

4. After booting you will want to go into your app drawer and open Superuser. It may request that you update the binaries, and you should allow it to. Going forward it will update via the Play Store like all of your other apps, and you should launch it afterwards to update the binary as well.

5. When finished, go to your Settings > Accounts and add your Google account since we skipped activation before. Proceed as normal setting up your phone. [/INFO]

Root It!
Answers and Solutions to Common Issues
Q. Will this void my warranty? And can I brick my device?
A. Not necessarily. In the strictest sense, unlocking and rooting will make your warranty voidable at the discretion of Google / LG. Meaning they can choose to not honor your warranty if you try to claim damages caused by your hacking ways. In practice you will often be able to receive appropriate warranty service a defective device even if you have unlocked / rooted it, but I cannot guarantee it for you. A Nexus device is almost impossible to actually "brick". Sometimes you may do something foolish and cause a "softbrick" which is actually very easily fixable. Check out my Factory Image Restore Guide to learn how to fastboot the factory images to your device no matter what you did to it and return it to brand new, out of the box condition. The same procedure can be used if you need to claim warranty service for an actual defective device and want to return it to stock before sending it in for repair/replacement.

Q. OH CRAP.. I bricked it. I don't know what I did but it's bootlooping and I don't know how to fix it. Am I screwed???
A. No! Relax. See the above answer and check out the Factory Image Restore Guide :)

Q. Will I continue to receive OTA (over-the-air) updates if I do this?
A. Yes.. my instructions are having you just boot into the custom recovery to flash SuperSU, we are leaving your stock recovery intact so that will not keep you from installing an OTA when it arrives. When you have root access you obviously have the ability to change your system files, and doing so could potentially cause an OTA to fail to install, as it needs to read your system as 100% stock. Additionally most OTA's will cause you to lose root access. You can easily re-root it following the exact same method we used here; or you can install OTA Rootkeeper and have that app backup your root access and restore it after the OTA. Which method you chose is up to you and either one will work just fine :)

Q. I don't want to fastboot the recovery every time I want to go flash something.. how do I flash it permanently?
A. First, understand that having a custom recovery permanently flashed will make you unable to receive OTA updates (you can very easily reflash the stock recovery though, I'll get to that). If you want to proceed anyway, using your new root access you want a file explorer that uses root. I prefer Root Explorer, but you can use Root Browser Lite if you want a free option. Using the app, locate the file "recovery-from-boot.p" in your /system directory. Long-press it and rename the file to something like "recovery-from-boot.p.bak".. this way you can easily rename it back later if you change your mind. Alternatively you could just delete it if this doesn't concern you. Now you can make your custom recovery stick when you fastboot it like before, but this time using the command:
Code:
fastboot flash recovery recovery.img
Where 'recovery.img' might be a different filename based on which recovery you are using, of course. Also of course there are apps that will flash the recovery for you if you are too lazy to fastboot, i.e. ROM Manager for CWM and GooManager for TWRP.

Q. Well I flashed the custom recovery permanently, I deleted the recovery-from-boot.p file, and now I want to receive an OTA but it won't install because I have a custom recovery. How do I reflash the stock recovery?
A. Grab the factory image from Google (link is available in my Factory Restore Guide). Extract it and also unzip the .zip file within, and look for the file named recovery.img. Simply use fastboot to flash this from the bootloader exactly like you flashed the custom recovery earlier.

Q. When entering the commands I see the error "fastboot is not a recognized command"
A. Your command prompt just isn't looking in the correct location. Remember you had to locate the directory which contains your fastboot file, move all of the files extracted from the Factory Image to that directory, and then either tell the command prompt to look in that directory or open the command window from within that directory. Go back to Step 2 of the step-by-step and try again.

Q. What the heck are you talking about?? Can't I just use a toolkit to do all of this for me? Why do you make it so complicated???
A. Sure you can. But you don't learn that way. A Nexus device is the easiest to unlock and root, you might as well spend a few minutes doing things manually and expanding your knowledge. Not to mention that toolkits can fail you, but knowing how to fastboot can save your life (and phone!). You learn a lot more doing things manually than just clicking a big ROOT ME button :)

Q. Why are we using TWRP Recovery? I thought Clockwordmod (CWM) was the best one?
A. I like it better, that's why, lol. Also it is less buggy than recent versions of CWM and the interface is nicer, IMO.

Q. But I want to use ROM Manager to flash recovery, or to flash ROMs, or .....
A. ROM Manager is buggy and I don't like it, but you can do what you want. TWRP has a similar app that will actually flash it for you if you like, check out GooManager. I still recommend people know how to flash recovery using fastboot, and know how to flash ROMs and files from within recovery, not from using an app like ROM Manager or GooManager.
Troubleshooting & FAQ

Thanks to everyone whose files, verbatim and other information I used while putting this guide together. If you have any further questions, issues or suggestions just post them up and myself or another member will be around as soon as possible to help you out :)

And please, if I failed to credit anyone properly, please PM me and I will be sure to rectify that!
In closing..
Nexus 4 Unlock and Root Guide
 
Last edited:

zero neck

The Ever-Living
Jan 13, 2011
3,127
1,386
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

looks dope.

however, i think the closing section should be changed to say "shout out my boy zero neck wihtout you i'm just an empty husk"

because it would be incredibly classy.
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

looks dope.

however, i think the closing section should be changed to say "shout out my boy zero neck wihtout you i'm just an empty husk"

because it would be incredibly classy.

Ya know that was in the first draft, not sure why I even changed it.
:)

Sent from my Galaxy Nexus using Tapatalk 2
 

digitalslacker

Well-known member
Jul 6, 2010
1,616
211
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

Your guides are awesome. Thanks, now I just need a Nexus 4 and I'll be all set :)

Sent from my Nexus 7 using Tapatalk 2
 

Saiga

Well-known member
Jul 22, 2011
153
1
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

Thanks for this great guide.

I seem to be lost in one spot though. In the "Recovery and Root" stage, on step 3, I don't see any where to tap "install zip from SD Card". Where should I be seeing that?

In my command prompt window, I have:

Sending 'recovery' <7628 KB>
OKAY
Writing 'recovery'
OKAY
Finished. total time: 0.905s

So it would appear that I have done the previous steps correctly, but I'm not understanding what I need to do next. Sorry for asking a lot of questions, I'm a complete newb at this.


UPDATE:

I used "fastboot boot cwm-recovery-mako.img" and I now see the option to install zip from sd card.

I now have a niffty Super SU icon :)
 
Last edited:

BoredandTattooed

Well-known member
Dec 7, 2010
196
1
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

Pardon my possible rudeness; but doesn't needing to root, unlock, etc totally defeat the point of getting a Nexus device? Though I know most of it is to be able to flash Roms...

Maybe I'm just old school... Sorry lol
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

Pardon my possible rudeness; but doesn't needing to root, unlock, etc totally defeat the point of getting a Nexus device? Though I know most of it is to be able to flash Roms...

Maybe I'm just old school... Sorry lol

Not at all.. Nexus devices are made to be easily unlocked, rooted and tinkered with, but of course you don't have to.

Flashing ROMs is one great thing to do, but not the only. Myself for example, I'm planning on staying on stock for at least a little bit before flashing on my Nexus 4, but I still have reason to root. I'm going to be using Titanium Backup to restore my apps and games data from my Galaxy Nexus to the Nexus 4 first off. Might use an ad blocker as well. Just a quick example.. But there are other reasons one may desire to unlock and root that don't always involve roms, although roms are a great option to have, even on a Nexus.

Sent from my Galaxy Nexus using Tapatalk 2
 

mzanette

Zee
Aug 22, 2012
826
14
18
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

I just want to be able to root the phone but also receive OTA updates like I do on my Nexus 7. I didn't flash CWM onto my Nexus 7, only unlocked and rooted, I didn't see that option for the phone yet, as there's a step to flash CWM..is this always needed?
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

I just want to be able to root the phone but also receive OTA updates like I do on my Nexus 7. I didn't flash CWM onto my Nexus 7, only unlocked and rooted, I didn't see that option for the phone yet, as there's a step to flash CWM..is this always needed?

The step included will not flash CWM, just boot you into it so that you can flash su. Your stock recovery will remain intact and you'll get OTAs assuming you don't change the system. You will likely lose root after an OTA unless you use OTA Rootkeeper, or else you can just reroot it just like the first time. :)

Sent from my Galaxy Nexus using Tapatalk 2
 

nexusisneecesary

Well-known member
Aug 31, 2012
149
0
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

Amazing guide this will definitely come in handy...once I have my n4:D:thumbup: although it may take me a while to get the money I need together...

Sent from my Nexus 7 using Tapatalk 2
 

peejay1977

Well-known member
Mar 26, 2010
207
0
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

Just a quick question, the Universal drivers don't support right-click and Install so is there an accepted method to force them to install? I have copied stuff to the INF folder in Windows before but I'm just mindful that uninstalling the drivers, rebooting will then reinstall the drivers that Windows wants to without prompting for a user location. I would normally have gone into Device Manager, right-click the device and chosen Update Driver and then pointed it manually to the driver location.

Not being pedantic, I haven't even got my Nexus 4 yet but just pre-empting a possible hurdle/question.

Thanks
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

Just a quick question, the Universal drivers don't support right-click and Install so is there an accepted method to force them to install? I have copied stuff to the INF folder in Windows before but I'm just mindful that uninstalling the drivers, rebooting will then reinstall the drivers that Windows wants to without prompting for a user location. I would normally have gone into Device Manager, right-click the device and chosen Update Driver and then pointed it manually to the driver location.

Not being pedantic, I haven't even got my Nexus 4 yet but just pre-empting a possible hurdle/question.

Thanks

Hmm.. I'll have to look into that when I get a chance.. I am spoiled by using Ubuntu as my primary OS so I don't worry about drivers, lol.

I'll see if I can get that clarified for you, and in the meantime if you are able to find an answer on your own please share it here and I'll be sure to make a note in the guide :)
 

peejay1977

Well-known member
Mar 26, 2010
207
0
0
Visit site
[GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

Hmm.. I'll have to look into that when I get a chance.. I am spoiled by using Ubuntu as my primary OS so I don't worry about drivers, lol.

I'll see if I can get that clarified for you, and in the meantime if you are able to find an answer on your own please share it here and I'll be sure to make a note in the guide :)

In fairness I could dual boot with Ubuntu but I'll see what happens when I (eventually) get mine :)
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Re: [GUIDE] Nexus 4 - Unlock, Flash Recovery, Root

In fairness I could dual boot with Ubuntu but I'll see what happens when I (eventually) get mine :)

That would be my recommendation ;)

I have dual-boot setup for Windows 7 and Ubuntu.. but as time goes on I use my Windows partition less and less, lol. Ubuntu ftw!
 

peejay1977

Well-known member
Mar 26, 2010
207
0
0
Visit site
I thought the same but video editing is far easier in Windows, I'll get it working, considering I've worked in IT for 17 years I'd rather hang myself than admit defeat! Lol
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Cleaned up some stuff, updated the CWM link to Koush's official build, added a few things to the FAQ....

Everyone finding things understandable, easy to follow, etc? I'm always open to suggestions and questions! :)
 

mzanette

Zee
Aug 22, 2012
826
14
18
Visit site
The step included will not flash CWM, just boot you into it so that you can flash su. Your stock recovery will remain intact and you'll get OTAs assuming you don't change the system. You will likely lose root after an OTA unless you use OTA Rootkeeper, or else you can just reroot it just like the first time. :)

Sent from my Galaxy Nexus using Tapatalk 2

Thank you this is perfect. Now I just need the phone. :)

Sent from my Nexus 7 using Android Central Forums
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Quick update.. the Universal Drivers pack was updated to 0.72 so I updated my dropbox and the link. Afaik the only change is that these drivers will support the Nexus 10 as well, so the 0.71 ones should work fine on the Nexus 4 if you already grabbed those, but I figure it's best to just keep everything updated anyways :)