yakimant
yakimant

Reputation: 95

Running tests on remote adb server

Trying to run gradle tests on remote adb server.

ADB_SERVER_SOCKET=tcp:host:port and ADB_DEVICE=emulator-5554 works fine for adb, but not gradle.

Looks like ANDROID_ADB_SERVER_PORT works for gradle, but I didn't find a way to set adb server host.

Upvotes: 2

Views: 1357

Answers (1)

bragoo
bragoo

Reputation: 46

What I can tell from Android Studio source code, it does not have support for reading in the host address. It's hard coded:

/**
 * Instantiates sSocketAddr with the address of the host's adb process.
 */
private static void initAdbSocketAddr() {
    try {
        sAdbServerPort = getAdbServerPort();
        sHostAddr = InetAddress.getByName(DEFAULT_ADB_HOST);
        sSocketAddr = new InetSocketAddress(sHostAddr, sAdbServerPort);
    } catch (UnknownHostException e) {
        // localhost should always be known.
    }
}

Adb reads ANDROID_ADB_SERVER_ADDRESS, so maybe one can extend Android Studio to use this env variable.

A workaround for now is maybe to use iptables to reroute the traffic from 127.0.0.1:5037 to whatever you want, see answer here.

Upvotes: 3

Related Questions