How to install Android Marshmallow on your Nexus device
Installing the Android Marshmallow image takes a little command-line know-how. And as is the case with any pre-release software, you may encounter unforeseen problems, so install Android 6.0 on a secondary device that you don’t rely on, or be prepared to risk losing your data.
Since installing the Marshmallow factory image will require you to wipe your phone, you’ll want to back it up before you begin. You’ll also want to update to the newest non-beta version of Android available—Android Lollipop 5.1.1 as of this writing—if you haven’t done so already. Updating now may save you headaches later on in this process.
Next, take a few minutes to download and install Google’s Android Studio developer tools if you don’t already have them installed. The installation process is pretty straightforward, and Google provides step-by-step instructions that explain how to do it. (If you don’t have Java installed on your computer, you’ll need to download and install that as well.)
Once you have the developer tools installed, go ahead and download the Android Marshmallow factory image from Google. Note that Google provides different preview builds for each device, so make sure you get the one made specifically for your device. You can get builds for the Nexus 5, Nexus 6, Nexus 9, and Nexus Player. The 2013 version of the Nexus 7 is supported, too.
Double-click the file you downloaded to unzip the image files. Keep these files in a safe place—we’ll come back to them in a few minutes.
Installing Marshmallow requires you to turn on Developer Mode on your phone. The process varies slightly depending on the version of Android you’re running, but on Android Lollipop, pop open the Settings app, scroll down, then tap About Phone. Scroll down to the Build number and tap it 7 times to unlock the developer options.
Now return to the main Settings screen, then scroll down and tap Developer options. Finally, toggle the switch for USB debugging to the on position and confirm when requested.
Next, find the folder containing the adb and fastboot tools that come with the Android developer tools. On OS X, these tools are tucked away in the hidden Library folder for your user account: To get to it, select Go to Folder... from the Finder’s Go menu, type ~/Library/Android/sdk/platform-tools/ into the text field, then press Go.
On Windows, you’ll find the folder on your C drive. The filename path will look something like C:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\platform-tools, though the names may vary slightly depending on which version of the developer tools you have installed. Your best bet may be to go to your C drive and poke around a bit.
Track down the image files you unzipped earlier, and move them to the folder containing adb and fastboot (it streamlines the process some by reducing the number of terminal commands you need to execute).
Now, we’ll make sure your computer can find your phone. Go ahead and plug your phone into your computer using a USB cable, and confirm the connection on your phone if prompted. To check for devices, open a Terminal or Command Prompt window (if you don’t know where to look, use your operating system’s search function to find the Terminal or Command Prompt).
Type cd followed by the filename path listed earlier into terminal then press enter—for example: cd ~/Library/Android/sdk/platform-tools/. The cd command is the same on both OS X and Windows; only the filename path format is different. Once you do that, type “adb devices” and press enter. You’ll see something like “0ae33abd02ba3467 device.” If you see that (the big string of letters and numbers will vary), you’re good to go. If not, go back and make sure you have USB debugging enabled on your Android device.
(Note: If you’re using OS X and you get an adb command not found message, try adding “./” in front of the commands you type—for example, ./adb devices. This tells the Terminal to look in the current folder for the adb tool. This applies to all commands mentioned in this article.)
Once your setup passes the adb devices test, type adb reboot bootloader and press enter: Your phone will now reboot into fasboot mode.
Take a look at your phone’s screen: If it says “locked state: locked,” you may need to unlock the phone’s bootloader first. Run the command fastboot oem unlock, then confirm on your phone that you want to unlock the bootloader. Note that doing so will erase all data on your phone, so be absolutely sure that this is necessary before you run this command.
Now that your bootloader is unlocked, it’s time to install the Marshmallow image on your phone. Type flash-all.bat (on Windows) or flash-all.sh (on OS X) to run the installation script, then press enter.
(Note: If running the script results in a string of command not found messages on OS X, you’ll actually have to open the script in a text editor—TextEdit works—then add “./” in front of all instances of “flash-all.sh” in the script, just as you did with terminal commands you entered. Save your changes then quit your text editor, and then try again.)
The flashing process takes some time, so be patient: Your phone will restart when the flashing process is complete. If all goes right, your phone will spring back to life with Android M installed. It may take your phone a while to boot back up the first time you restart, so don’t panic if your phone is stuck on the boot screen for several minutes.
If you unlocked your bootloader, you may want to lock your bootloader again for security reasons, so reenable developer options and USB debugging, then boot into fastboot mode using the adb reboot bootloader command, then run the fastboot oem lock command: Depending on your device, you may lose your data again. Press your power button to restart your phone one last time.
You’re all finished. Go and have fun exploring Android Marshmallow!