So, you've got a Nexus device and keep hearing about these factory images, but have no idea what to do with them. It's ok—we're here to help. This guide will take you from a locked Nexus device to an unlocked device with the latest Android software on it.

First, though, a warning: this will delete everything on your device. Factory images do a full wipe of your data partition, meaning your apps, settings, passwords, game saves, pictures, and everything else will be erased. Back up the stuff you want to keep.

Download the SDK and image

First click here and download the "Eclipse ADT Bundle" from Google. This is the Android SDK. You'll need this to get your computer to talk to your phone, unlock your bootloader and push over the new files. It will work on Windows, Mac OS X, and Linux.

It would also be a good idea to download the correct factory image for your device.

Unzip the file and, on Windows, you'll need to run the "SDK Manager." The most important thing you'll need here is the Google USB Driver, which should be checked by default. It's a good idea to let it update the "Android SDK Tools" and "Android SDK Platform-tools," but you can uncheck everything under "Android 5.X;" that's all emulator stuff that we don't need. Mac and Linux users should be good with the regular download.

Start in Fastboot mode and unlock your bootloader

Ron Amadeo

Ron Amadeo

Next you'll need to put your device in "Fastboot" mode, which will allow you to wipe out the current Android install and send over a new version from a desktop computer. To enter fastboot, power off the device and turn it on by holding volume down and power until you see the first screen above. Some devices might require you to hold down Volume up, volume down, and power.

From here, grab the factory image you downloaded, unzip it, and place the contents in the "Platform Tools" directory of the SDK. Make sure you aren't just copying a single folder into "Platform Tools." The key here is that the "flash all" files end up in the same folder as the file called "fastboot."

Next you'll need to "unlock" your device. This isn't referring to carrier unlock, but rather unlocking your bootloader so you can flash a new version of Android. At the bottom of the Fastboot screen, there should be a line that says "LOCK STATE," which will say either "locked" or "unlocked." We want it to say "unlocked" so that we can flash what we want to the device.

Either way, while on the fastboot screen, it's time to plug the device into your computer and run some commands. Fire up a terminal/command prompt and navigate to the Platform Tools directory. If your phone says "LOCK STATE — locked" on the Fastboot screen while your phone is still in Fastboot mode, you'll need to run "fastboot oem unlock." This will pop up the next screen in the gallery, above.

Saying "yes" to this will be the first of two data wipes that will happen, so make sure you're ready for all your data to be deleted. To navigate on this screen, the volume buttons are up and down, and "power" will select your choice. Pick "yes" and the phone will unlock and wipe itself.

Flash the image file

For the next step, you need to be in Fastboot mode again, so if the phone booted into the welcome screen, turn it off and turn it on while holding the "volume down" button to get back into fastboot. Now you just need to run the "flash all" file.

On Windows this is a .bat file. Double clicking on "Flash-all.bat" should take care of it.

On Mac OS, you'll need to add the "Platform Tools" directory to your $PATH variable. That means opening up a terminal, typing "sudo nano /etc/paths," entering your password, and adding the path of the "Platform Tools" directory to the bottom of the file. Then hit "control+X" on the keyboard, "y" and then "enter" to save, and you're done. Then you just need to run "flash-all.sh" from the terminal.

Then just wait a long time for the flash to happen, the device to reboot, and for your new version of Android to boot. The first boot can take a very long time, so be patient.