9

In the Android gradle plugin there are options for aapt and dex but I can't find where I can pass parameters to the adb used by tasks such as install and connectedCheck (and any other that would use adb to complete).

My problem is that I want to pass the -H flag pointing to a remote adb. The use case is to run my tests on a remote machine (and then maybe, machineS). I believe this was possible with Android Maven plugin but I want to do it in Gradle now.

I have access to both machines and have tested that I can list and install a package using the -H flag but it seems like that android-gradle is hard coding 127.0.0.1.

If anyone has a working example of running the tests on different adb hosts could you please share it here?

Olinasc
  • 1,261
  • 1
  • 12
  • 20

2 Answers2

0

I ran into the same issue and found a working solution by setting the environment variable ANDROID_ADB_SERVER_ADDRESS. I discovered it by digging through the adb source code.

You can see it also checks for ANDROID_ADB_SERVER_PORT and ANDROID_SERIAL if you need to change either of those too.

Kevin Brotcke
  • 3,765
  • 26
  • 34
  • This has been a long time :) But last I checked, Gradle was overwriting these variables (not ADB). I don't have the setup right now to reproduce this, but let's see what other people find. – Olinasc Sep 29 '17 at 19:59
  • Yeah, I take it back. This works fine for ADB, but Gradle is overwriting the host and it doesn't check the ADB host environment variable like it does for the port one. – Kevin Brotcke Oct 02 '17 at 20:26
  • Well... it has been like that for more than 3 years now :) Thanks for your support anyway. – Olinasc Oct 08 '17 at 02:41
-1

I'm facing the same problem. This guy wrote a java app (linked in the third comment to the post) that forwards adb connections to a remote adb server. This might be a workaround?

Community
  • 1
  • 1
jbxbergdev
  • 860
  • 1
  • 10
  • 23
  • I'd have added a comment instead if i had enough reputation. However, I do think that the solution in my link might be a good alternate approach to the problem for some. – jbxbergdev Oct 29 '15 at 16:19
  • P.S. The question was "If anyone has a working example of running the tests on different adb hosts could you please share it here?" The app linked in my answer actually allows precisely for that. – jbxbergdev Oct 29 '15 at 16:24