This page provides details for running builds on specific devices. These details complement the information in Building Android.
Build fastboot and adb
If you don't already have fastboot
and adb
, you can
build them with the regular build system. Use the instructions in
Building Android and replace the
main make
command with this one:
make fastboot adb
See Android Debug Bridge (adb) for details on Android Debug Bridge (adb).
Boot into fastboot mode
You can flash a device when it's in the fastboot
bootloader
mode. To enter fastboot
mode when a device is undergoing a cold
boot, use the key combinations listed in
Fastboot key combinations.
You can also use the command adb reboot bootloader
to reboot
directly into the bootloader. See
Flashing instructions for full instructions.
Unlock the bootloader
You can flash a custom system only if the bootloader allows it. Note, though, that the bootloader is locked by default. You can unlock the bootloader, but doing so deletes user data for privacy reasons. After unlocking, all data on the device is erased, that is, both private app data and shared data accessible over USB (including photos and movies). Before attempting to unlock the bootloader, back up any important files on the device.
You need to unlock the bootloader only once, and you can re-lock it if necessary.
Unlock recent devices
All Nexus and Pixel devices released since 2014 (starting with Nexus 6 and Nexus 9) have factory-reset protection and require a multistep process to unlock the bootloader.
- To enable OEM unlocking on the device:
- In Settings, tap About phone, then tap Build number seven times.
- When you see the message You are now a developer!, tap the back button.
- In Settings, tap System, then tap Developer options and enable OEM unlocking and USB debugging. (If OEM unlocking is disabled, connect to the internet so the device can check in at least once. If it remains disabled, your device might be SIM locked by your carrier and the bootloader can't be unlocked.)
- Reboot into the bootloader and use
fastboot
to unlock it.- For newer devices (2015 and higher):
fastboot flashing unlock
- For older devices (2014 and lower):
fastboot oem unlock
- For newer devices (2015 and higher):
- Confirm the unlock onscreen.
Re-lock the bootloader
To re-lock the bootloader:
- For newer devices (2015 and higher):
fastboot flashing lock
- For older devices (2014 and lower):
fastboot oem lock
Use flash lock states
The getFlashLockState()
system API transmits the bootloader
state and the PersistentDataBlockManager.getFlashLockState()
system
API returns the bootloader's lock status on compliant devices.
Return value | Conditions |
---|---|
FLASH_LOCK_UNKNOWN |
Returned only by devices upgrading to Android 7.x or higher that didn't
previously support the bootloader changes required to get the flash lock
status if they supported flashing lock/unlock capability.
|
FLASH_LOCK_LOCKED |
Returned by any device that doesn't support flashing lock/unlock (that is, the device is always locked), or any device that supports flashing lock/unlock and is in the locked state. |
FLASH_LOCK_UNLOCKED |
Returned by any device that supports flashing lock/unlock and is in the unlocked state. |
Manufacturers should test the values returned by devices with locked and
unlocked bootloaders. For an example, the Android Open Source Project (AOSP)
contains a reference implementation that returns a value based on the
ro.boot.flash.locked
boot property. Example code is located in the
following directories:
frameworks/base/services/core/java/com/android/server/PersistentDataBlockService.java
frameworks/base/core/java/android/service/persistentdata/PersistentDataBlockManager.java
Select a device build
The recommended device builds are available from the lunch
menu, accessed when running the lunch
command with no arguments.
For additional information on the lunch
command, see
Choose a target.
For a list of build targets, see
Build targets.
You can download factory images and binaries for Pixel and Nexus devices from developers.google.com. See Device binaries for downloads. For details and additional resources, see Obtaining proprietary binaries.
Device | Code name | Build configuration |
---|---|---|
Pixel 7 Pro | cheetah | aosp_cheetah-userdebug |
Pixel 7 | panther | aosp_panther-userdebug |
Pixel 6 Pro | raven | aosp_raven-userdebug |
Pixel 6 | oriole | aosp_oriole-userdebug |
Pixel 5 | redfin | aosp_redfin-userdebug |
Pixel 4a 5G | bramble | aosp_bramble-userdebug |
Pixel 4a | sunfish | aosp_sunfish-userdebug |
Pixel 4 XL | coral | aosp_coral-userdebug |
Pixel 4 | flame | aosp_flame-userdebug |
Pixel 3a XL | bonito | aosp_bonito-userdebug |
Pixel 3a | sargo | aosp_sargo-userdebug |
Pixel 3 XL | crosshatch | aosp_crosshatch-userdebug |
Pixel 3 | blueline | aosp_blueline-userdebug |
Pixel 2 XL | taimen | aosp_taimen-userdebug |
Pixel 2 | walleye | aosp_walleye-userdebug |
Pixel XL | marlin | aosp_marlin-userdebug |
Pixel | sailfish | aosp_sailfish-userdebug |
HiKey | hikey | hikey-userdebug |
Nexus 6P | angler | aosp_angler-userdebug |
Nexus 5X | bullhead | aosp_bullhead-userdebug |
Nexus 6 | shamu | aosp_shamu-userdebug |
Nexus Player | fugu | aosp_fugu-userdebug |
Nexus 9 | volantis (flounder) | aosp_flounder-userdebug |
Nexus 5 (GSM/LTE) | hammerhead | aosp_hammerhead-userdebug |
Nexus 7 (Wi-Fi) | razor (flo) | aosp_flo-userdebug |
Nexus 7 (Mobile) | razorg (deb) | aosp_deb-userdebug |
Nexus 10 | mantaray (manta) | full_manta-userdebug |
Nexus 4 | occam (mako) | full_mako-userdebug |
Nexus 7 (Wi-Fi) | nakasi (grouper) | full_grouper-userdebug |
Nexus 7 (Mobile) | nakasig (tilapia) | full_tilapia-userdebug |
Galaxy Nexus (GSM/HSPA+) | yakju (maguro) | full_maguro-userdebug |
Galaxy Nexus (Verizon) | mysid (toro) | √aosp_toro-userdebug |
Galaxy Nexus (Experimental) | mysidspr (toroplus) | aosp_toroplus-userdebug |
Motorola Xoom (U.S. Wi-Fi) | wingray | full_wingray-userdebug |
Nexus S | soju (crespo) | full_crespo-userdebug |
Nexus S 4G | sojus (crespo4g) | full_crespo4g-userdebug |
Flash a device
You can flash an entire Android system in a single command; doing so verifies
that the system being flashed is compatible with the installed bootloader and radio,
writes the boot, recovery, and system partitions together, then reboots the
system. Flashing also erases all user data, similarly to fastboot oem
unlock
.
To flash a device:
- Unzip the image file to its own directory.
- Set the
ANDROID_PRODUCT_OUT
environment variable to point to the same directory used in step 1. - Place the device in
fastboot
mode by holding the appropriate key combination at boot or using the following command:adb reboot bootloader
- After the device is in fastboot mode, run:
fastboot flashall -w
The-w
option wipes the/data
partition on the device; this is useful for your first time flashing a particular device but is otherwise unnecessary.
Flash configurations
Fastboot instructions are spelled out in an artifact called fastboot-info.txt which lives in
$ANDROID_PRODUCT_OUT/*
This .txt document list of tasks for fastboot to execute and
can be regenerated via m fastboot_info
. Custom flashing logic can be introduced
by modifying this file
supported commands:
- flash %s : Flash a given partition. Optional arguments include
--slot-other, {filename_path}, --apply-vbmeta
- update-super : Updates the super partition
- if-wipe : Conditionally run some other functionality if wipe is specified
- erase %s : Erase a given partition (can only be used in conjunction)
with if-wipe -> eg.
if-wipe erase cache
Restore devices to factory state
Factory images for Google devices are available from Factory Images for Nexus and Pixel Devices. Factory images for the Motorola Xoom are distributed directly by Motorola.
Resolve permission denied errors
By default on most Linux systems, unprivileged users can't access USB ports. If you see a permission denied error, refer to Android Studio's instructions to Set up a device for development.
If adb was already running and can't connect to the
device, you can stop adb with adb kill-server
. This command causes adb to restart with
the new configuration.