Registry / database / adb-shell

adb-shell

JSON →
library0.4.4pypypi✓ verified 85d ago

A Python implementation of ADB with shell and FileSync functionality. Current version 0.4.4, somewhat irregular release cadence.

pip install adb-shell
INSTALL
IMPORT
SIG · ADB-SHELL
A
adb-shell
databasepythonv0.4.4
Install
3.5s avg
Import
208ms
Disk
35MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.222s · 37.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.5s · import 0.194s · 38MB
35MB installed
● package 35MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AdbDeviceTcp
from adb_shell.adb_device import AdbDeviceTcp
from adb_shell import AdbDeviceTcp
AdbDeviceTcp is not at the package root; must import from submodule.
AdbDeviceUsb
from adb_shell.adb_device import AdbDeviceUsb
from adb_shell.adb_device import AdbDeviceUsb
AdbCommands
from adb_shell.adb_device import AdbCommands
from adb_shell import AdbCommands
Must import from adb_device submodule.

Connect to an ADB device over TCP and run a shell command.

from adb_shell.adb_device import AdbDeviceTcp from adb_shell.auth.sign_pythonrsa import PythonRSASigner # Load the RSA key pair (usually from ~/.android/adbkey and adbkey.pub) with open('~/.android/adbkey', 'r') as f: priv = f.read() with open('~/.android/adbkey.pub', 'r') as f: pub = f.read() signer = PythonRSASigner(pub, priv) device = AdbDeviceTcp('localhost', 5555) device.connect(rsa_keys=[signer], auth_timeout_s=10) print(device.shell('echo hello')) device.close()
Debug
Known issues
gotchaImporting from adb_shell directly (e.g., `from adb_shell import AdbDeviceTcp`) raises ImportError. Always import from the submodule `adb_shell.adb_device`.
fix
Use `from adb_shell.adb_device import AdbDeviceTcp`.
affects: all
gotchaThe `close()` method must be called after finishing to release transport resources. Failing to do so may cause resource leaks.
fix
Always call `device.close()` or use a context manager (if available).
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'adb_shell'
Package not installed or installed with wrong name.
fix
Run `pip install adb-shell` (the package name on PyPI is adb-shell, not adb_shell).
AttributeError: module 'adb_shell' has no attribute 'AdbDeviceTcp'
Incorrect import path; AdbDeviceTcp is in adb_device submodule.
fix
Use `from adb_shell.adb_device import AdbDeviceTcp`.
ConnectionRefusedError: [Errno 111] Connection refused
ADB server not running or device not connected on the specified host/port.
fix
Ensure ADB server is running (`adb start-server`) and device is connected (`adb devices`). Verify host and port (default 5555).
Upgrade
Version history
0.4.4latest on PyPI · released Sep 1, 2023
Audit
Dependencies
rsarequiredRequired for ADB authentication
cryptographyrequiredRequired for ADB authentication
aiofilesoptionalRequired for async file operations
asyncsshoptionalExperimental ADB over SSH support
Agent activity
39 hits · last 30 days
node
34
OpenAI (training)
1
Resources
adb-shell — pip install adb-shell · libregistry