facebookarchive / stetho

Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
http://facebook.github.io/stetho/
MIT License
12.66k stars 1.13k forks source link

Add support for ADB_SERVER_SOCKET in dumpapp #623

Closed asm89 closed 5 years ago

asm89 commented 5 years ago

There are multiple ways to set the adb server connection information in the environment. This commit adds support for ADB_SERVER_SOCKET.

Set a valid server socket environment variable:

$ export ADB_SERVER_SOCKET=tcp:localhost:5038
$ adb devices
List of devices attached
* daemon not running; starting now at tcp:localhost:5038
* daemon started successfully

Now dumpapp doesn't fail anymore:

$ scripts/dumpapp
Failure to target device None: no devices/emulators found

It does fail when the socket spec is invalid/unsupported:

$ export ADB_SERVER_SOCKET=nope
$ scripts/dumpapp
...
stetho_open.HumanReadableError: Invalid or unsupported socket spec 'nope' specified in ADB_SERVER_SOCKET.
$ export ADB_SERVER_SOCKET=tcp:localhost:abc
$ scripts/dumpapp
...
stetho_open.HumanReadableError: Invalid integer 'abc' specified in ANDROID_ADB_SERVER_PORT or ADB_SERVER_SOCKET.
jasta commented 5 years ago

Great work, thanks!