Building adb and fastboot command from AOSP source code

adb, android debugging brige, is used for connecting your PC and Android devices to get log, send command to Android devices etc which is very useful for Android software development.

fastboot command is used to control bootloader mode for Nexus devices, it can be used to flash new factory image etc.

Here the method of how to build adb command and fastboot command manually from Android Open Source Project source code is written. If you feel it trouble some to build adb and fastboot command manually in your PC, see also

I used Linux OS (Ubuntu 14.4) for following set up.

Step 1. Build Environment setup

If your PC does not have building environment for AOSP yet, you can set up by just following Establishing a Build Environment.

Step 2. Downloading AOSP Source code

Follow Downloading the Source.

Step 3. Build adb and fastboot

Go to your source code root directory, and set up build environment by

$ source build/envsetup.sh (or $ . build/envsetup.sh)
$ lunch

After lunch command, following will appear so that you can choose your buildtype.

~/workspaces/aosp$ lunch

You're building on Linux

Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_mips-eng
4. aosp_mips64-eng
5. aosp_x86-eng
6. aosp_x86_64-eng
7. aosp_deb-userdebug
8. aosp_flo-userdebug
9. full_fugu-userdebug
10. aosp_fugu-userdebug
11. aosp_grouper-userdebug
12. aosp_tilapia-userdebug
13. mini_emulator_arm64-userdebug
14. m_e_arm-userdebug
15. mini_emulator_mips-userdebug
16. mini_emulator_x86_64-userdebug
17. mini_emulator_x86-userdebug
18. aosp_flounder-userdebug
19. aosp_hammerhead-userdebug
20. aosp_mako-userdebug
21. aosp_shamu-userdebug
22. aosp_manta-userdebug

Which would you like? [aosp_arm-eng]

You can type number and press enter to proceed. In my case, I want to build for Nexus Player so I chose 10 (aosp_fugu-userdebug). 

Finally we can build by

$ make adb fastboot

make will takes several minutes to build adb and fastboot.

Step 4. Adding a environment path

Immediately after building, you can find these command by,

$ which fastboot
~/workspaces/aosp/out/host/linux-x86/bin//fastboot
$ which adb
~/workspaces/aosp/out/host/linux-x86/bin//adb

It is better to set environment path (because after this log in session finishes, this path setting will be removed).

# Environment path setting for adb & fastboot
export PATH=~/workspaces/aosp/out/host/linux-x86/bin/:$PATH

Step 5. Check function

Finally you can check if fastboot and adb is working correctly or not.  

adb

First is to check adb, connect your PC and Android device by USB. Enable developer mode for your Android device, and after enable USB debugging, type 

$ adb devices

It should show device which PC is connecting to. Try sudo if it is not working.

fastboot

Finally check fastboot. Reboot your Nexus devices with bootloader mode

$ adb reboot bootloader

After Nexus reboots with bootloader mode, type

$ fastboot devices
XXXXXXXX fastboot

and check if you can see devices or not. try sudo if it is not working, or it says “waiting for devices” forever. If fastboot is not working, you may need to set up Android device udev rules (refer below links).

Reference

Leave a Comment

Your email address will not be published. Required fields are marked *