JADB Documentation

repository·master·Indexed 20 days ago

https://github.com/vidstige/jadb

A pure Java implementation of the Android Debug Bridge (ADB) protocol. JADB enables Java applications to perform device management, file transfers, and package installation on Android devices without requiring native binaries.

Tokens
718
Snippets
4
Records
5
Agent score
22%

What's inside JADB

  1. Quickstart with JADB

    master

    To use JADB, create a JadbConnection instance. This connection allows you to interact with the ADB server to manage devices and perform operations. Ensure the ADB server is running on your host machine (e.g., by running adb from the command line) before attempting to connect.

    JadbConnection jadb = new JadbConnection();
    List<JadbDevice> devices = jadb.getDevices();
  2. Add JADB to a Maven project via JitPack

    master

    JADB is not available in official Apache Maven repositories. To use it in a Maven project, you must add the JitPack repository and then include the dependency using the com.github.vidstige groupId.

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
    
    <dependencies>
        <dependency>
            <groupId>com.github.vidstige</groupId>
            <artifactId>jadb</artifactId>
            <version>v1.2.1</version>
        </dependency>
    </dependencies>
  3. Workaround for Unix Sockets ADB Server

    master

    If your ADB server is using Unix domain sockets instead of TCP, you can use socat to forward port 5037 to the Unix socket, allowing JADB to connect via TCP.

    socat TCP-LISTEN:5037,reuseaddr,fork UNIX-CONNECT:/tmp/5037
  4. Troubleshoot connection issues

    master

    If you cannot connect to your device via JADB, verify the following:

    1. ADB Server Status: Ensure the ADB server is running by executing adb start-server in your terminal.
    2. Device Visibility: Verify the device is visible to the standard ADB tool by running adb devices.

    If the device appears in adb devices but is not detected by JADB, please report the issue on the project's GitHub repository.

  5. Manage files and packages on a JadbDevice

    master

    Once you have a JadbDevice instance, you can perform several high-level operations:

    Pulling files

    Use device.pull(RemoteFile, File) to copy a file from the Android device to your local filesystem.

    Installing packages

    Use the PackageManager class to install or uninstall APKs on the device.

    // Pull a file from the device
    JadbDevice device = ...
    device.pull(new RemoteFile("/path/to/file.txt"), new File("file.txt"));
    
    // Install an APK
    JadbDevice device = ...
    new PackageManager(device).install(new File("/path/to/my.apk"));