Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Recently I had a problem where my Nexus S phone would not upgrade to Jelly Bean. During the upgrade process I was getting an error message saying one of the files on my current system is corrupted, so the upgrade cannot be applied.

I knew clean install (instead of an upgrade) would fix the issue, but I had a really hard time finding clear information on how to do this. Most tutorials require you to download the new OS from untrusted sources (shady download sites) and assume your phone is rooted.

Thankfully as it turned out you can do this using official Google software only and you don't need to root your phone (you can - it doesn't matter).

I post instructions for the method I used, as an answer below. This is also useful when you need to do a true factory reset. The "factory reset" function in Android only clears user data, leaving the OS as it was - useless if your operating system is damaged or if it was modified and you would like to bring it to an original, stock state. This solves the problem.

This instructions should work for any Nexus phone or tablet.

share|improve this question

2 Answers 2

up vote 12 down vote accepted

Beware: The instructions are for clean installing an OS. That means ALL YOUR DATA will be permanently LOST. If your phone was previously rooted it will be brought back to an unrooted state (whether you want it or not).

Please, remember to make backups of any important data on your phone. It will be lost.


1. Turning on USB debuging

Turn on USB debugging on your device:

Go to System settings / Developer options and check "USB debugging".

2. Fastboot

You will need the fastboot tool. It's an official Google command line tool intended for developers. You can follow the official instructions for installing the tool, but they are pretty complicated. If you are on Mac OS X or Linux you should probably do what I've done and use the adb-fastboot-install open source tool.

Just download it, unzip it and use one of the following command line instructions (depending on your operating system):

sh ADB-Install-Mac.sh

or

sh ADB-Install-Linux.sh

Obviously while doing that you need to be inside the directory containing those files.

There are plenty of instructions on how to install fastboot on Windows (for example this one). See also user17512's answer for an alternative method for Windows users.

3. Going to device's fastboot mode

You need to connect the device to your computer using a USB cable and then access your device's fastboot mode:

  • On Nexus S: Turn off your phone. Press and hold Volume Up, then press and hold Power.

  • On Galaxy Nexus, Nexus 5 and Nexus 10: Turn off your phone. Press and hold both Volume Up and Volume Down, then press and hold Power.

  • On Nexus 4 and Nexus 7: Turn off your device. Press and hold Volume Down, then press and hold Power.

4. Unlocking the bootloader

Execute the following command on your computer:

fastboot oem unlock

Note: this step will remove all your data from the device.

5. Downloading the factory image

Download the factory image for your particular device and your desired Android version directly from Google.

6. Installing the system

Unpack the archive (if you are on Windows you will probably need to download additional software for unpacking .tar.gz files. 7-zip will do the job. Mac and Linux users have all the required software installed already).

Go inside the newly unarchived directory and execute the following command:

./flash-all.sh

Note: This will wipe all data from your device

After some time your device should reboot and boot to your newly installed operating system :)

7. Relocking your bootloader

This step is not strictly necessary, but it's a good idea for security reasons. Reboot to the fastboot mode again (see step 2 above) and execute the following command on your computer:

fastboot oem lock

This worked great for me, I hope it will be helpful to other people :)

share|improve this answer
    
Very very helpful, it works for me on a Nexus S. Thanks a lot for sharing, knowledge is the power. –  bobighorus Apr 4 '13 at 15:16

If you have Windows, the excellent Nexus Root Toolkit will automate the process that was given here into a one click 'flash to stock & unroot' plus an additional option to OEM lock afterwards. Of course it will unlock and root just as easily and other advanced features. You can get it at:

http://www.wugfresh.com/dev/nexus-root-toolkit/

share|improve this answer

protected by Community Dec 6 '12 at 13:48

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.