{"id":20895,"library":"adb-shell","title":"adb_shell","description":"A Python implementation of ADB with shell and FileSync functionality. Current version 0.4.4, somewhat irregular release cadence.","status":"active","version":"0.4.4","language":"python","source_language":"en","source_url":"https://github.com/JeffLIrion/adb_shell","tags":["adb","android","shell","file-sync"],"install":[{"cmd":"pip install adb-shell","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for ADB authentication","package":"rsa","optional":false},{"reason":"Required for ADB authentication","package":"cryptography","optional":false},{"reason":"Required for async file operations","package":"aiofiles","optional":true},{"reason":"Experimental ADB over SSH support","package":"asyncssh","optional":true}],"imports":[{"note":"AdbDeviceTcp is not at the package root; must import from submodule.","wrong":"from adb_shell import AdbDeviceTcp","symbol":"AdbDeviceTcp","correct":"from adb_shell.adb_device import AdbDeviceTcp"},{"wrong":"from adb_shell.adb_device import AdbDeviceUsb","symbol":"AdbDeviceUsb","correct":"from adb_shell.adb_device import AdbDeviceUsb"},{"note":"Must import from adb_device submodule.","wrong":"from adb_shell import AdbCommands","symbol":"AdbCommands","correct":"from adb_shell.adb_device import AdbCommands"}],"quickstart":{"code":"from adb_shell.adb_device import AdbDeviceTcp\nfrom adb_shell.auth.sign_pythonrsa import PythonRSASigner\n\n# Load the RSA key pair (usually from ~/.android/adbkey and adbkey.pub)\nwith open('~/.android/adbkey', 'r') as f:\n    priv = f.read()\nwith open('~/.android/adbkey.pub', 'r') as f:\n    pub = f.read()\n\nsigner = PythonRSASigner(pub, priv)\ndevice = AdbDeviceTcp('localhost', 5555)\ndevice.connect(rsa_keys=[signer], auth_timeout_s=10)\nprint(device.shell('echo hello'))\ndevice.close()","lang":"python","description":"Connect to an ADB device over TCP and run a shell command."},"warnings":[{"fix":"Use `from adb_shell.adb_device import AdbDeviceTcp`.","message":"Importing from adb_shell directly (e.g., `from adb_shell import AdbDeviceTcp`) raises ImportError. Always import from the submodule `adb_shell.adb_device`.","severity":"gotcha","affected_versions":"all"},{"fix":"Always call `device.close()` or use a context manager (if available).","message":"The `close()` method must be called after finishing to release transport resources. Failing to do so may cause resource leaks.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `pip install adb-shell` (the package name on PyPI is adb-shell, not adb_shell).","cause":"Package not installed or installed with wrong name.","error":"ModuleNotFoundError: No module named 'adb_shell'"},{"fix":"Use `from adb_shell.adb_device import AdbDeviceTcp`.","cause":"Incorrect import path; AdbDeviceTcp is in adb_device submodule.","error":"AttributeError: module 'adb_shell' has no attribute 'AdbDeviceTcp'"},{"fix":"Ensure ADB server is running (`adb start-server`) and device is connected (`adb devices`). Verify host and port (default 5555).","cause":"ADB server not running or device not connected on the specified host/port.","error":"ConnectionRefusedError: [Errno 111] Connection refused"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}