The definitive guide on hacking the Nexus 4, part 3: How to install a custom ROM

galaxy

The definitive guide on hacking the Nexus 4, part 3
This is part 3 of an 8 part series of articles on the Nexus 4. This guide assumes that you have already successfully installed the ADB drivers for the Nexus 4 (part 1), and that you have succesfully unlocked the bootloader, rooted and installed ClockworkMod (part 2).  This guide will describe how to install a custom ROM. This is the exciting part!

Legal disclaimer: We are not responsible for any damage or loss to your device or computer system. Therefore, should you decide to follow these steps, you do so at your own risk and peril and agree to hold us harmless from any damage or loss you may experience. Should you disagree with the foregoing, please do not read any further.

What is a custom ROM?
When the Android development community refers to custom ROM’s, what they mean is a custom version of Android that has been modified or enhanced somehow. The installation process is similar to wiping Windows Vista (horrendous) on your PC to install Windows 8. In other words, you clear the memory in the system in order to install a new operating system. That’s what we’ll be doing below.

ROM stands for “Read Only Memory”. This implies that you can read from memory, but you cannot write on it. ROM by definition means that you cannot modify it, flash it or change it in anyway. This is a bit confusing as we’ll be flashing a custom ROM below. However, we’re “hacking” Android in order to accomplish this. Nintendo games are a good example of a ROM. You can save your progress on a part of the cartridge, but the game itself is read only memory. There is some debate on whether or not the term “custom firmware” would be more apropos than “custom ROM”. For example, users install a custom firmware on their router, but no one says that they are installing a custom ROM on their router. Almost every other embedded device in the world uses the term “firmware”, except for Android. Smartphone manufacturers may use the term ROM because they want its users to think that it unmodifiable, but that’s clearly not true. Suffice to say, this is probably a semantic dispute not worth fighting. As far as Android phones are concerned, the Android development community overwhelming decided to use the term “custom ROM”, so that’s what we’ll be using.

Why would you want to install a custom ROM?
This is probably one of the most common questions that we receive. There are a number of reasons why one should use a custom ROM, especially for Touchwiz, HTC Sense, etc. users running older versions of Android. Those users would benefit the most since they will receive the latest version of Android right away. However, there are undoubtedly fewer benefits for Nexus 4 users as they already receive OTA updates directly from Google.  It’s important to remember that you tend to lose the ability to get OTA updates from Google when you install a custom ROM, but the ROM developer will send you updates instead (so you won’t be left behind). Here are a couple of reasons why you should install a custom ROM. You can read more reasons here, here, here and here.

  1. Performance. There are potential performance improvements in Custom ROM’s. In our experience, we find certain ROMs to be more fluid and smooth than stock Android. You can also potentially overclock your phone to get better performance.
  2. Battery Life. Potentially, you can get better battery life as certain ROMs are optimized for this purpose. You can also underclock and undervolt your phone if you desire.
  3. Personalization. If you like to customize your phone, you will love custom ROM’s. There are usually plenty of new configuration menus, therefore you can configure your phone exactly the way that you like it. Custom ROM’s typically add new useful features and options that make Android more useable and friendly. There’s really too many features to list.
  4. More updates. You’re a techie and you love being on the bleeding edge of technology. You can even set up certain ROM’s to auto-update every night as some developers upload nightly tests builds for users to try out the latest builds. This is what we do.
  5. Fun. If you like to tinker with software, you should install a custom ROM. There’s no real downside as modern Android phones are very difficult to brick. You can always revert back to stock if you change your mind.
  6. Bragging rights.

How to install a custom ROM
There are many popular custom ROM developers for the Nexus 4, but the most popular is CyanogenMod (which is what we’ll be installing below). Another great choice is AOKP. AKOP might even have more features than CyanogenMod. Therefore, if you have the time and the volition, you should try both. The steps are basically the same. You just need to download the latest AOKP build instead of the latest CyanogenMod build. Also, you should also look into this app called ROM Manager, it’s developed by the same person that developed ClockworkMod. It allows you to install custom ROM’s and its updates right in Android. However, you may need to buy the $5.99 Premium version to access some features. We like to do things old school, so we’re going to flash the ROM through ClockworkMod.

1) Download the latest CyanogenMod nightly zip file onto your PC. The latest build is at the top of the page. It’s approximately 177MB. Do not unzip it. Nightly builds are supposed to be experimental and not for daily use, but we’ve never had any problems running them. We’ve never seen a single crash or “forced closed”. It’s been nothing but butter smooth. No features are known to be broken. Wifi hotspot, GPS and standard wifi are all working perfectly in CyanogenMod. It’s important to note that wifi hotspot on LTE data does not work out of the box (as this phone was never supposed to support LTE), but we’ll show you how to fix this in part 6.

2) Download the latest version of Google Apps onto your PC. The latest version is near the top of the table. It’s approximately 90MB. Do not unzip it. This is a collection of Google’s most popular apps, gmail, google maps, etc. (apps that you cannot download from the Play Store). Google asked the Android development community not to bundle Google’s apps with custom ROM’s. That’s why you need to flash the Google Apps separately. Back in the day, they used to be all bundled together.

3) This step is optional. If you’re the paranoid sort and you’re afraid of bricking your phone. You can help minimize the risk of installing a corrupted zip file by running a “checksum” test to make sure that the 2 downloaded zip files have not been corrupted. MD5 checksum is a popular way to check the integrity of a file. To do this, download, install and run this small free tool called WinMD5. Go back to the two pages where you downloaded the zip files and you’ll notice a series of seemingly random sequence of letters and numbers below the download links, as seen below. This is the MD5 checksum hash code. Copy these codes.

md52

 

md5x

To verify the integrity of the zip files, click “Browse” in the WinMD5 program to select the first zip file and paste the matching MD5 checksum found on the webpage into the white box in WinMD5 labelled “Original file MD5 checksum value” and click “Verify”. If the hashes match, it means that the file is not corrupted. Do the same for the other zip file. If the hashes don’t match, it means that you either selected the wrong zip file, you copied and pasted the wrong checksum or the downloaded zip file is corrupted (so you should download it again).

md5
4) Now, let’s transfer those 2 zip files to your phone. Connect your Nexus 4 to your PC via a USB cable and transfer both files to a directory of your phone. To do this, open up explorer (the windows file manager) on your PC and you should see an icon like below.

1

If you don’t see your phone appear in explorer, you may need to disable USB Debugging and enable (Media Transfer Protocol) MTP by clicking on “Connected as media device”. Once you connect your phone to a PC, the “Connected as media device” notification will usually appear. You can enable MTP through this notification.

Screenshot_2013-02-24-02-29-53

MTP

Double click on the Nexus 4 icon in the file manager on your PC and you should see the contents of your phone. We’re going to make a new directory called “ROM” inside the sdcard of the Nexus 4. You may not see a directory called “sdcard” on your PC (you’ll probably just see “Internal Storage”), but it’s the folder with sub-directories such as “Android”, “DCIM”, “Download”, etc. The final result in the ROM directory should look something like below.

internal

5)    Let’s boot into Fastboot mode. So, disconnect the USB cable and turn off your phone. To enter into Fastboot mode (while the phone is off), push and hold volume up and volume down and the power button (hold all three together) for a few seconds. Once the phone vibrates and you see a little android man, as seen below, you can let go of all 3 buttons. The bootloader should be unlocked when you’re installing a custom ROM and Kernel. It may work even if it’s locked, but it’s best not to take chances.

photo2

6)    Push volume down 2 times until the “Start” menu has changed to “Recovery Mode”, as shown below. Once you see “Recovery Mode”, push power to select it. Your phone will now start ClockworkMod–which is the Android custom recovery we installed in Part 2.

7)    If you see something like below, that means that you’re in ClockworkMod. This is where the magic happens. Before we install the Custom ROM, let’s do some house cleaning to avoid possible conflicts (old system files mixing with new system files, it’s not pretty). Please note that the following steps will wipe your user data, so backup anything that you need before doing this. You can navigate through ClockworkMod with the Volume Up/Volume Down buttons or you can touch the screen to select a menu option.

First, select “wipe cache partition” and select “Yes – Wipe Cache”.
Secondly, go back to the main screen and select “advanced”, select ”wipe dalvik cache” then select “Yes – Wipe Dalvik Cache”.
Thirdly, go back to the main screen and select “wipe data/factory reset” and click “Yes – Wipe data/factory reset”.

wipecache
wipe dalvik

8)    Once that is complete, let’s install the custom ROM. Select “install zip from sdcard” from the home screen of ClockworkMod, then navigate to the “ROM” folder you created beforehand.  To do that, open the folder called “0″ (this may be different on your phone), then select the folder called “ROM” then select the Cyanogenmod zip file. The installation process should look something like this. It will finish installing very quickly.

installingrom

9)    Afterwards, let’s install the Google Apps. Go back to the home screen of ClockworkMod and select “install zip from sdcard”, select a folder called “0″ (this may be different on your phone), then select the folder called “ROM” then select the Google Apps zip file. The installation process should look something like this. It will install quickly as well.

gapps

10) Go back to the ClockworkMod home screen and select “Reboot System Now”. Your phone should reboot and you should see a new boot screen with a new CyanogenMod animation. That’s a first sign that it seems to be working. If the phone stays on this animated screen for more than 5 minutes, you probably got yourself stuck in a co-called “boot loop”. In this case, go back into Fastboot mode and re-do all of the steps and try again.

Once the phone is fully booted, go into “Settings” then “About phone” and you should see something like below. Here you have a confirmation that you’re running CyanogenMod. CyanogenMod has a lot of neat features, so feel free to play around to explore the new options. Finally, give yourself a pat on the back and go have a cold beer. You deserve it.

Please stay tuned for Part 4 where we will discuss what is a Kernel and how to do install a custom Kernel. Kernel hacking is what separates the men from the boys. We’ll discuss more about this in Part 8 where we’ll try to optimize the Kernel for maximize battery life.

Screenshot_2013-02-24-03-05-43

  • Robert Navarro

    Thanks for this guide, i was able to install a custom rom, now i can see the full potential of the Nexus 4! Not hard at all, just be patient and follow step by step and everything will be good to go! :D

    • Hippowise

      That’s great! I’m very happy to hear that it wasn’t too painful :)

  • Felipe Cebada

    Hello! Is there a method to install a custom ROM (I am thinking in CM) but keeping the baseband? You know, I´ve 4G in my Nexus already using your tutorial and Baseband is 33. Or should I have to install CM and after, follow the steps of enablig LTE again? Please advice. Thanks a lot in advance!

    • Hippowise

      If I understand your question correctly. You’re currently running CM, downgraded to baseband .33 and got LTE working. However, you’re wondering if you can install a different custom ROM within Android without having to re-enable LTE again? If what you’re describing is possible, I wouldn’t know how. Typically, when you install a new custom ROM, all of the files that you edited are replaced with whatever came with the ROM. I suppose that anything is possible, but I’m not aware of an easy way to do it.

      • Felipe Cebada

        Thank you. I have stock ROM in my Nexus. All the rest is exactly what I asked. So I understand now that after installing any nightly CM ROM, I would need to follow the steps of Part 5. Correct me if I am wrong. It´s just that would be great to have a shortcut for keeping LTE. :).

        Thanks!

        • Hippowise

          I am not aware of any easy way to keep LTE unfortunately. I think that you will have to re-enable LTE again. It’s not too painful luckily ;)

  • thedonj77

    I was wondering if you could perhaps do an article on how to go from one rom to another or provide a quick link or tutorial

    • Hippowise

      I actually switched from cyanogenmod to paranoid android a few days ago. It’s pretty neat. The steps are pretty much the same.

      1) download the custom ROM from your phone, the latest gapps and baseband .33, the 3 zip files are usually saved at /sdcard/Download
      2) turn off your phone and boot into clockworkmod recovery
      3) wipe cache partition, wipe dalvik cache and wipe data/factory reset

      4) install the new rom ROM, then gapps then baseband .33
      5) restart into android, do the steps to permanently enable LTE
      6) do a factory reset
      7) boot into android and LTE should be activated in the new ROM

  • thedonj77

    Thanks as always

  • Felipe Cebada

    Hello! I have another question: once a new nightly version of CyanogenMode is available for downloading (using settings in the Nexus 4) you need to download it and flash it through CM Recovery? Or does it have auto flash feature? Thanks in advance.

    • Hippowise

      Cyanogenmod is pretty smart, so it autoflashes. In other words, you don’t need to enter clockworkmod. For example, once a new nightly update is available, you will receive a notification. If you click download it will then ask you if you wish to “auto flash”. If you click that it will reboot and flash and start android right away. You don’t need to do anything else.

      • Felipe Cebada

        Thank you!! I will wait.

        • Hippowise

          You don’t have to wait to receive a notification. It checks daily or once a week (depending on what the default setting is). You can check immediately if there is an update by going into settings/about phone and uhh.. cyanogenmod updates? I’m doing this from memory :)

  • Damon

    Im new to putting ROM’s on, and i already have TWERP recovery, will it switch out twerp and add a new recovery? Also i already have franco kernel flashed onto it will i have to remove it and then flash the ROM or just re-flash franco after i flash the ROM?

    • Hippowise

      If you install new ROM, it will not affect your custom recovery. Therefore, if you already have Teamwin’s TWRP recovery installed, it will remain there. You can install the custom ROM using TWRP instead of Clockworkmod. The principle is the same, it’s just a different recovery. Some may even argue that TWRP is better than Clockworkmod. However, when you install a new ROM, it will replace whatever kernel you currently have installed with the default Cyanogenmod kernel. If you wish to install the franco kernel on top of Cyanogenmod, you need to install the franco kernel after you’ve installed the new ROM. I hope that helps.

      • Damon

        Thank you very much, that clears up a lot :)

  • colorskied

    I’m having issues with step 4. Specifically, for anything to work with my HP Win 7 laptop I need to have MTP unchecked and PTP checked. When I try to create a folder in my nexus 4 through the explorer, it says “The new folder could not be created in this location. The device has either stopped responding or has been disconnected.” I haven’t changed anything through all the previous steps. The device is connected, turned on, nothing indicating that it cannot connect. How am I able to access the file structure if its not connected?? Any ideas on bypassing this step and somehow copying ROM zips to the phone???

  • emoliveto

    Great guide. I only have one question. If i have a Nexus 4 with 4.4.2 stock installed could i downgrade to CM 10.2? I mean i have to first downgrade to 4.3 or i can install cm 10.2 like you explain? Sorry for my english.