Here is the step by step tutorial to flash a stock ROM in Google Nexus 4.
DISCLAIMER : Best Android Blog would not be held responsible/liable for any damages that occur to your device by following the given below procedure. So, do everything at your own risk.
A. How to Install the drivers:
1. First, do not install the LG drivers or the PDAnet drivers, or any other driver you come across. Just in case, if you have, and if you are sure they work properly just leave them or else uninstall them.
3. After that install the drivers. Note that the driver has to install twice: once when your device is booted normally with USB Debugging enabled in Settings, and once when your device is booted in fastboot (i.e., bootloader) mode. (To enable USB Debugging, you first need to enable Developer options by going to Settings->About phone and tapping 7 times on the build number.) If you are using Windows 8, you will need to do this before installing the drivers.
B. Backup your data:
- The given below procedure will wipe the data which you have in your device and also in SD Card. So, we strongly recommend you to take backup of all your internal datas, apps, photos, music, APN Settings, Contacts, Call register and whatever you have.
C. Download the required files to your computer and extract them:
1. Download the required files and extract the contents to the same directory without any sub-folders. It is important that everything should be in the same folder. It doesn’t matter what the name of the folder.
2. Next download the version of the Android you want from here. Make sure you are using an occam image which is for the Nexus 4. Most old versions are not usually available on that site; however, there is a mirror on this site: Random Phantasmagoria.
3. Next download the appropriate version (for your computer) of 7-zip from here and install it.
4. Extract the files from within the .tgz file which you downloaded in step 3 using 7-zip, not WinZip or WinRAR or whatever.
5. Make sure you have extracted ALL the files (including extracting any files in any archives inside the .tgz file). You should have six (6) files ending with .img in the directory you created in step 1. The other files you extracted from the .tgz are not necessary.
6. Reboot your device into bootloader mode (by turning it off, hold volume down, and press and hold power) and plug it into your computer.
7. Open a command prompt in the same directory (i.e., make sure you are in the same directory as your files are located). You can hold the shift key when you are in the folder in Windows explorer and right-click in a blank spot and it will open a command prompt.
D. Type in the Commands into the command prompt:
1. Make sure your computer recognizes your device by typing: fastboot devices.
2. Next Unlock your bootloader (if you have not already done so): fastboot oem unlock.
3. You will see a prompt on your device. This will wipe your entire device (including the /sdcard folder). Accept.
Note: Use the volume keys to change the option and the power button to accept. You cannot use the touch screen.
4. Reboot by typing: fastboot reboot-bootloader
5. Flash the bootloader: fastboot flash bootloader bootloader-mako-makoz10l.img (or whatever the name of the bootloader image that you downloaded).
6. Reboot: fastboot reboot-bootloader
7. Flash the radio: fastboot flash radio radio-mako-m9615a-cefwmazm-2.0.1700.33.img (or whatever the name is of the radio image that you downloaded).
8. Reboot: fastboot reboot-bootloader
9. Flash the system partition: fastboot flash system system.img
10. Optional (NOT optional for noobs) – Flash the data partition: fastboot flash userdata userdata.img.
Note: This command will wipe your device (including /sdcard), EVEN if your bootloader is already unlocked.
11. Flash the kernel/ramdisk: fastboot flash boot boot.img
12. Optional (NOT optional for noobs) – Flash the recovery partition: fastboot flash recovery recovery.img
13. Erase the cache partition: fastboot erase cache
14. Reboot: fastboot reboot
15. That’s it You’ve Done! The first boot will take the longer time than the expected time, because android builds the Dalvik cache.
Now you have a fully stock image on your device. The only thing that is different from out-of-the-box condition is that your bootloader is unlocked.
NOTE : Do not relock your bootloader after you are finished. Having an unlocked bootloader does not affect anything related to the ROM/Google Wallet/OTAs. If it is locked, you cannot use fastboot commands. This is pretty much the only thing it affects. If your bootloader is locked, and you need to unlock it, it will wipe everything, including /sdcard. This is the major drawback of re-locking your bootloader. If you do want to lock your bootloader, the command is: fastboot oem lock