Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Install Android M Preview on Nexus: Mac & Linux Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can install the Android M Developer Preview on a Nexus device from a Mac or Linux computer. The process uses the official Android SDK tools (fastboot and adb) to unlock the bootloader, flash the preview images, and re-lock it if you wish. You'll need a compatible Nexus device (Nexus 5, 6, 9, or Player), a USB cable, and about 30 minutes. The steps below are for the official Google images—no unofficial builds or hacks.

What You'll Need

  • A supported Nexus device (check the official list for the preview—typically Nexus 5, 6, 9, and Nexus Player).
  • A Mac or Linux computer with a USB port.
  • The official Android M Preview factory image for your exact device model (download from Google's developer site).
  • Android SDK Platform Tools (contains adb and fastboot). You can install via Android Studio or download the command-line tools.
  • USB drivers for your device (on Mac/Linux, usually built-in, but if your device isn't recognized, install the appropriate driver).
  • A backup of your device data—flashing wipes everything.

Step-by-Step

  1. Back up your data. Flashing the preview will erase your device. Sync photos, contacts, and any files you want to keep to cloud or computer.
  2. Install the Android SDK Platform Tools. Download the official command-line tools from Google's developer site, or install Android Studio and use its SDK manager. Extract the zip to a folder (e.g., ~/android-sdk). The adb and fastboot binaries will be in platform-tools/.
  3. Enable Developer options and USB debugging on your Nexus. Go to Settings > About phone and tap “Build number” seven times. Then go to Settings > Developer options and enable “USB debugging”.
  4. Connect your device to your computer via USB. On the phone, accept the “Allow USB debugging” prompt.
  5. Verify adb sees your device. In a terminal, navigate to the folder with adb (e.g., cd ~/android-sdk/platform-tools) and run ./adb devices. You should see your device listed as “device”. If it shows “unauthorized”, re-check the phone prompt.
  6. Unlock the bootloader. Run ./adb reboot bootloader. The device will reboot into the bootloader (fastboot mode). Then run ./fastboot oem unlock. On the device, use the volume keys to select “Unlock” and press power to confirm. This wipes your data and unlocks the bootloader.
  7. Download and extract the factory image. Get the correct image for your device model from Google's developer page. Extract the zip—you'll get a folder with several files, including flash-all.sh (for Mac/Linux).
  8. Run the flash script. In a terminal, navigate to the extracted folder. Run ./flash-all.sh. The script will flash the bootloader, radio (if any), and system images. Wait for the process to finish—it may take several minutes. Do not unplug the device.
  9. Reboot and set up. The script will reboot the device automatically. You'll see the Android M welcome screen. Follow the setup steps.
  10. Re-lock the bootloader (optional but recommended). After setup, if you want to lock the bootloader for security, reboot to bootloader (./adb reboot bootloader) and run ./fastboot oem lock. Confirm on the device. This wipes data again, so do it before you set up your apps.

Common Mistakes

  • Wrong factory image: Flashing an image for a different model (e.g., Nexus 5 image on Nexus 6) will fail or brick. Double-check your device model in Settings > About phone.
  • USB debugging not enabled: If adb doesn't see your device, you haven't enabled USB debugging or haven't accepted the prompt on the phone.
  • Driver issues on Mac/Linux: On Mac, you may need to install the Android File Transfer app for proper USB communication. On Linux, you might need to add a udev rule for your device vendor.
  • Running the flash script from the wrong directory: The script uses relative paths. Make sure you're in the extracted folder when you run ./flash-all.sh.
  • Skipping the backup: Unlocking the bootloader wipes your device. If you skip backup, you lose everything.

Tips

  • Use a short, high-quality USB cable. Long or faulty cables cause connection drops during flashing.
  • Keep your device charged above 50% to avoid shutdown mid-flash.
  • If you're on Linux, you may need to run fastboot with sudo if you haven't set up udev rules. Try sudo ./fastboot devices to check.
  • Take note of your device's model number (e.g., Nexus 5 is “hammerhead”, Nexus 6 is “shamu”). The factory image filenames include these code names.
  • After flashing, consider keeping the bootloader unlocked if you plan to flash future previews—but be aware it makes your device less secure.

Troubleshooting

If something goes wrong, start with the simplest fixes:

  • Device not detected by adb: Replug the USB cable, restart adb server (./adb kill-server then ./adb start-server), and re-enable USB debugging on the phone.
  • Fastboot says “no devices” or “device not found”: Ensure you're in bootloader mode (you should see the bootloader screen). Try a different USB port (preferably a rear port on a desktop). On Linux, check lsusb to see if the device appears.
  • Flash script fails with “error: cannot load 'bootloader.img'”: You're running the script from the wrong directory. Navigate to the extracted folder and run ./flash-all.sh from there.
  • Device stuck in bootloop after flashing: This usually means the image didn't flash completely. Reboot to bootloader (hold power + volume down for a few seconds) and run the flash script again. If it persists, try a factory reset from recovery mode.
  • Bootloader unlock prompt doesn't appear: On some devices, you may need to run ./fastboot oem unlock twice or ensure you're using the latest fastboot version.
  • If all else fails: Download the factory image again (in case of corruption), and try a different USB cable/port. If the device is bricked (won't power on), you may need to use the manufacturer's recovery tool—but that's rare.

Frequently Asked Questions

Will installing the preview void my warranty?

Unlocking the bootloader and flashing a preview typically voids the warranty from the manufacturer. If you re-lock the bootloader and restore a stock image, some manufacturers may still honor it, but it's not guaranteed.

Can I go back to the official Android version after the preview?

Yes. Download the latest factory image for your device from Google's developer site and flash it using the same process. You'll lose all data, so back up first.

Do I need to root the device first?

No. The preview images are flashed using fastboot, which works on a locked bootloader (after unlocking). Rooting is not required.

Will this work on a Nexus 7 or other older device?

The Android M Preview was officially released for Nexus 5, 6, 9, and Nexus Player. Other devices are not supported and may not have compatible images.

What if I don't see “Developer options” in Settings?

Go to Settings > About phone and tap “Build number” seven times. After that, Developer options will appear in the main Settings menu.

Is it safe to unlock the bootloader?

Unlocking the bootloader is safe in the sense that it doesn't damage hardware, but it wipes your data and reduces security. It also allows anyone with physical access to your device to flash software. Re-locking after flashing restores some security.