Dec 26, 2012

How to root Nexus 4

Unlocking The Bootloader And Obtaining Root

This part of the tutorial is geared towards Windows users. The MAC instructions are very similar, from what I understand. Install the package the same way. All ADB/Fastboot commands may need to start with "adb-mac" (no quotes) rather than "adb" (no quotes). Due to the vast amount of Linux distros available; instructions will vary for your device. OnceADB/Fastboot are set up all command will begin with "./adb" (no quotes) rather than "adb" (no quotes). Once ADB/Fastboot are set up; this guide is relevant to everyone.

Time required: 20-40 minutes.

Setting up ADB for our device:
Cyanogenmod has a guide that you can follow to set up ADB.
Note: There isn't a .zip available anymore. Just use the .exe and install it directly to the C:\ path when the installer asks.
Or you can use this page to download the "ADB for Dummies AIO App."
This will automatically install ADB for you to your C:\ directory. It's very very simple this way.
If your platform-tools folder doesn't have a fastboot.exe, place this fastboot.exe file in your D:\android-sdk-windows\platform-tools (or possibly simply called tools, if you set up ADB ages ago) folder.
Now you have ADB installed! Congratulations.

Unlocking the Bootloader:

This may perform a factory reset on your device. You might lose all applications. Even the data on your SD Card! I'd recommend making a Backup to your computer BEFORE performing this. There is a method for backing your data up, detailed in the "ADB BACKUP" tab.

Get the drivers:
Uninstall any previously attempted drivers if they don't work and move to the next.
Option One: Steps 16-27.
Option Two: Try this one as well. Use CyanogenMod's Guide for installing ADB - Steps 16 through 27 replacing the file/location with the naked drivers.
PDAnet's drivers may work if the above options don't. Simply install PDAnet (after uninstalling any previous attempted driver installations) to get the drivers.
While that is downloading, on your Nexus 4: turn USB debugging on.
This can be found in Settings>Developer Options>USB Debugging
Once the drivers are installed, navigate to the C:\android-sdk-windows\platform-tools folder on your computer.
Hold shift and right click. Select "Open Command Window Here."
On your phone: turn USB Debugging On. This can be found in Settings>Developer Settings.
Plug your phone into the computer. Now in this command window type:

adb reboot bootloader
(Hit Enter)

Your phone should now boot into a screen with a green android with his chest exposed.
Type this:

fastboot oem unlock
(Hit Enter)

If your Command Prompt displays the message "waiting for device" your driver wasn't successfully installed.
Close the Command Prompt window and open Device manager while your phone is still plugged in. (Search for it using the search option).
Right Click the "Android" option and select Update Driver. Choose to "Browse My Computer" and "Let Me Pick From A List." Pick the Driver with the newest date and install it. Now retry the code above.
Your phone will ask if you want to unlock it. Select "Yes" by using the volume keys and use power to select it.
Now, navigate to "Recovery Mode" with the volume keys. Use power to select.
A screen with another Android will pop up. Press Volume Up and Power at the same time.
Select Factory Reset. This process may take a few minutes. Be patient and let it work.
Once finished, select "Reboot."
Your phone is now unlocked!

Obtaining Root Access and Custom Recovery:

Turn on USB Debugging in Settings>Developer Options>USB Debugging.
Download the following:
SuperSU (CWM .zip)
CWM (Pick the version for your device)

Place the recovery-clockwork-VERSIONNUMBER-mako.img file into your C:\android-sdk-windows\platform-tools folder.
Put the on your phone.
Open another Command Prompt if it isn't still open. (Navigate to C:\android-sdk-windows\platform-tools and shift + right click. Select "Open Command Window Here.")
With your phone plugged in type:


adb reboot bootloader
(Hit Enter)
And wait for your phone to boot into the android again.
Now type:
fastboot flash recovery IMAGENAME.img
(Change the file name to the correct file name and Hit Enter)
Once that is finished: select the "Recovery Mode" option again on your phone.
You should get a new recovery menu here. Select "install zip from sd card" and "choose zip from sd card."
Find the that you transferred earlier and select "Yes" to installing.
Navigate back to "Reboot" and reboot your phone.
You're now rooted! However, ClockworkMod Recovery won't continue to load after this.
To fix this, find "Rom Manager" from the market. (The free version is fine.) Use the "Flash ClockworkMod Recovery" option. If your recovery still doesn't stick around after a reboot, you have another couple options. Find a file explorer that allows root access, such as Root Explorer. Use this program to rename /system/etc/ to /system/etc/install-recovery.bak. You'll need to mount the system as r/w to do this. Root Explorer provides a button at the top to do so.
Or, you can do this completely manually by firing up ADB again and running a few commands:

adb shell
(Hit Enter)Code:
(Hit Enter)
mount -o remount,rw -t ext4 /dev/block/mmcblk0p1 /system
(Hit Enter)


mv /system/etc/ /system/etc/install-recovery.bak
(Hit Enter)

Congratulations! Your phone is now unlocked, rooted, and has a custom recovery!

No comments: