{"id":8332,"library":"mozdevice","title":"Mozdevice (Mozilla Device Management)","description":"Mozdevice is a Python library developed by Mozilla for managing and interacting with mobile devices (Android, Firefox OS/B2G) via ADB, as well as desktop browsers. It provides functionalities for device introspection, application management, and remote command execution, primarily used in automated testing and development workflows. The current version is 4.2.0, with an active release cadence driven by Mozilla's mobile testing needs. It requires Python 3.6 or newer.","status":"active","version":"4.2.0","language":"en","source_language":"en","source_url":"https://github.com/mozilla-mobile/mozdevice","tags":["mobile","android","adb","testing","device-management","mozilla"],"install":[{"cmd":"pip install mozdevice","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for parsing application manifests (e.g., Firefox OS apps).","package":"manifest-parser","optional":false}],"imports":[{"note":"DeviceManager is located in the 'devicemanager' submodule, not directly under the top-level 'mozdevice' package.","wrong":"from mozdevice import DeviceManager","symbol":"DeviceManager","correct":"from mozdevice.devicemanager import DeviceManager"}],"quickstart":{"code":"import os\nfrom mozdevice.devicemanager import DeviceManager\n\ntry:\n    # Connect to a locally available ADB device\n    # If multiple devices are connected, you might need to specify 'serial'\n    dm = DeviceManager()\n    print(f\"Connected to device: {dm.name}\")\n    print(f\"Device type: {dm.device_type}\")\n    print(f\"Device OS: {dm.os}\")\n\n    # Example: Get a list of installed packages (Android)\n    if dm.os == 'android':\n        packages = dm.list_packages()\n        print(f\"Number of installed packages: {len(packages)}\")\n        # print(f\"Sample packages: {packages[:5]}\")\n\nexcept Exception as e:\n    print(f\"Error connecting or interacting with device: {e}\")\n    print(\"Please ensure ADB is installed and a device is connected and authorized.\")","lang":"python","description":"This quickstart connects to a locally available Android device via ADB, retrieves basic device information, and lists installed packages. Ensure ADB (Android Debug Bridge) is installed and configured in your system's PATH, and a device is connected and authorized."},"warnings":[{"fix":"Install Android SDK Platform-Tools (which includes ADB) and ensure its location is added to your system's PATH environment variable. Verify with `adb devices` command.","message":"Mozdevice relies on ADB (Android Debug Bridge) being installed and accessible in your system's PATH. Without a correctly set up ADB environment, device connection will fail.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using Python 3.6 or a newer version (e.g., `python3.9 -m pip install mozdevice`).","message":"The minimum Python version required is 3.6. While PyPI metadata might sometimes show `None` for `requires_python`, the project's `setup.cfg` explicitly states `>=3.6`.","severity":"breaking","affected_versions":"<4.0 (for older Python), >=4.0 (strictly Python 3.6+)"},{"fix":"Initialize `DeviceManager` with `DeviceManager(serial='<DEVICE_SERIAL>')` for specific local devices, or `DeviceManager(addr='<REMOTE_IP>', port=<REMOTE_PORT>)` for remote connections. Use `adb devices` to find local device serials.","message":"Connecting to specific devices when multiple are present or connecting to remote devices requires specifying connection parameters (e.g., `serial`, `addr`, `port`) during `DeviceManager` initialization.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install Android SDK Platform-Tools and ensure the directory containing `adb` is in your system's PATH. Alternatively, set the `ADB_EXEC_PATH` environment variable to the full path of the `adb` executable before running your Python script.","cause":"The ADB executable is not found in the system's PATH or ADB_EXEC_PATH environment variable, or it's not executable.","error":"mozdevice.errors.ADBError: ADB executable not found. Make sure it's in your PATH or specify ADB_EXEC_PATH."},{"fix":"Ensure your device is physically connected, USB debugging is enabled, and the device is authorized for ADB debugging. Run `adb devices` in your terminal to confirm the device is listed. If connecting remotely, verify IP/port and network accessibility.","cause":"Mozdevice could not find any connected or specified device via ADB.","error":"mozdevice.errors.DeviceConnectionError: No devices attached or available."}]}