Python ADB + Fastboot implementation
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead, 12 commits behind google:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Coverage Status Build Status

This repository contains a pure-python implementation of the ADB and Fastboot protocols, using libusb1 for USB communications.

This is a complete replacement and rearchitecture of the Android project's ADB and fastboot code

This code is mainly targeted to users that need to communicate with Android devices in an automated fashion, such as in automated testing. It does not have a daemon between the client and the device, and therefore does not support multiple simultaneous commands to the same device. It does support any number of devices and never communicates with a device that it wasn't intended to, unlike the Android project's ADB.

Using as standalone tool

Running ./ creates two files: and They can be run similar to native adb and fastboot via the python interpreter:

python devices
python shell ls /sdcard

Using as a Python Library

A presentation was made at PyCon 2016, and here's some demo code:

import os.path as op

from adb import adb_commands
from adb import sign_m2crypto

# KitKat+ devices require authentication
signer = sign_m2crypto.M2CryptoSigner(
# Connect to the device
device = adb_commands.AdbCommands.ConnectDevice(
# Now we can use Shell, Pull, Push, etc!
for i in xrange(10):
  print device.Shell('echo %d' % i)


  • Simpler code due to use of libusb1 and Python.
  • API can be used by other Python code easily.
  • Errors are propagated with tracebacks, helping debug connectivity issues.
  • No daemon outliving the command.
  • Can be packaged as standalone zips that can be run independent of the CPU architecture (e.g. x86 vs ARM).


  • Technically slower due to Python, mitigated by no daemon.
  • Only one command per device at a time.
  • More dependencies than Android's ADB.


  • libusb1 (1.0.16+)
  • python-libusb1 (1.2.0+)
  • one of:
    • python-m2crypto (0.21.1+)
    • python-rsa (3.2+)
  • (optional):
    • python-progressbar (2.3+)



  • Initial version


  • Added TcpHandle (jameyhicks)
  • Various timing and other changes (alusco)