[
https://issues.jboss.org/browse/ARQ-1534?page=com.atlassian.jira.plugin.s...
]
Stefan Miklosovic edited comment on ARQ-1534 at 10/26/13 7:21 PM:
------------------------------------------------------------------
[~kpiwko]
In connection to this problem, it is good idea to clarify whole adb connections related
process. From
https://developer.android.com/tools/help/adb.html :
{quote}
Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with
an emulator instance or connected Android-powered device. It is a client-server program
that includes three components:
*A client*, which runs on your development machine. You can invoke a client from a shell
by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create
adb clients.
*A server*, which runs as a background process on your development machine. *The server
manages communication between the client and the adb daemon running on an emulator or
device*.
*A daemon*, which runs as a background process on each emulator or device instance.
When you start an adb client, the client first checks whether there is an adb server
process already running. If there isn't, it starts the server process. *When the
server starts, it binds to local TCP port 5037* and listens for commands sent from adb
clients—*all adb clients use port 5037 to communicate with the adb server*.
The server then sets up connections to all running emulator/device instances. *It locates
emulator/device instances by scanning odd-numbered ports in the range 5555 to 5585, the
range used by emulators/devices. When the server finds an adb daemon, it sets up a
connection to that port.* Note that each emulator/device instance acquires a pair of
sequential ports — an even-numbered port for console connections and an odd-numbered port
for adb connections.
{quote}
In order to specify adb server port where Android debug bridge should be bound to, you
have to set environment variable
{code}
ANDROID_ADB_SERVER_PORT
{code}
to whatever port you want. After it, when new instance of adb server is started, it is
bound to that specified server port or to 5037 by default when not specified differently.
When you want to start adb server manually on the command line with non-default port, you
have to do it like this
{code}
adb -P 10000 fork-server server
{code}
so by specifying different port every time, you have multiple instances of adb bridge
which in turn means that when you are about to start an emulator, ddmlib tries to connect
its client to ANDROID_ADB_SERVER_PORT or by default to 5037.
You can set adbPort configuration property right now in arquillian.xml but it serves as
"odd-numbered" port mentioned above where emulator instance is bound so that
started server daemon on arbitrary port (by env port set) connects afterwards.
It seems that when ANDROID_ADB_SERVER_PORT is set and tests are executed, emulator adb
client starts to communicate with server instance bound to that port so it seems that it
does not collide with Eclipse.
Moreover, I noticed that error messages are written out to Eclipse console output only
when Android emulator is started and I kill the only running instance of Android debug
bridge (so no adb server is running) so Eclipse's adb client listens to void which is
the cause of that error output.
In addition, that environment property is read from System.getenv and if we wanted to be
able to change that port from arquillian.xml, there would have to be kind of ugly hack to
modify environment property map after JVM has read that since it can not be modified once
created (by default, but it can be hacked afterwards and the result of this is rather
questionable).
was (Author: smikloso):
[~kpiwko]
In connection to this problem, it is good idea to clarify whole adb connections related
process. From
https://developer.android.com/tools/help/adb.html :
{quote}
Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with
an emulator instance or connected Android-powered device. It is a client-server program
that includes three components:
*A client*, which runs on your development machine. You can invoke a client from a shell
by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create
adb clients.
*A server*, which runs as a background process on your development machine. *The server
manages communication between the client and the adb daemon running on an emulator or
device*.
*A daemon*, which runs as a background process on each emulator or device instance.
When you start an adb client, the client first checks whether there is an adb server
process already running. If there isn't, it starts the server process. *When the
server starts, it binds to local TCP port 5037* and listens for commands sent from adb
clients—*all adb clients use port 5037 to communicate with the adb server*.
The server then sets up connections to all running emulator/device instances. *It locates
emulator/device instances by scanning odd-numbered ports in the range 5555 to 5585, the
range used by emulators/devices. When the server finds an adb daemon, it sets up a
connection to that port.* Note that each emulator/device instance acquires a pair of
sequential ports — an even-numbered port for console connections and an odd-numbered port
for adb connections.
{quote}
In order to specify adb server port where Android debug bridge should be bound to, you
have to set environment variable
{code}
ANDROID_ADB_SERVER_PORT
{code}
to whatever port you want. After it, when new instance of adb server is started, it is
bound to that specified server port or to 5037 by default when not specified differently.
When you want to start adb server manually on the command line with non-default port, you
have to do it like this
{code}
adb -P 10000 fork-server server
{code}
so by specifying different port every time, you have multiple instances of adb bridge
which in turn means that when you are about to start an emulator, ddmlib tries to connect
its client to ANDROID_ADB_SERVER_PORT or by default to 5037.
You can set adbPort configuration property right now in arquillian.xml but it serves as
"odd-numbered" port mentioned above where emulator instance is bound so that
started server daemon on arbitrary port (by env port set) connects afterwards.
It seems that when ANDROID_ADB_SERVER_PORT is set and tests are executed, emulator adb
client starts to communicate with server instance bound to that port so it seems that it
does not collide with Eclipse.
Moreover, I noticed that error messages are written out to Eclipse console output only
when Android emulator is started and I kill the only running instance of Android debug
bridge (so no adb server is running) so Eclipse's adb client listens to void which is
the cause of that error output.
There is no way how to set server port of Android Debug Bridge
--------------------------------------------------------------
Key: ARQ-1534
URL:
https://issues.jboss.org/browse/ARQ-1534
Project: Arquillian
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Extension - Droidium
Affects Versions: droidium_1.0.0.Alpha2
Reporter: Karel Piwko
Assignee: Stefan Miklosovic
*Given*:
I have Android tooling installed in Eclipse/JBDS.
*When:*
I use Droidium in tests fro IDE.
*Expect*:
No having any errors in DDMS output in IDE.
*Additional information*:
It looks like that the problem is that Droidium does not allow to set android bridge
server port and hence DDMS is already connected to given port. This leads to various
errors logged, as DDMS is not prepared to handle external process changing it's
environment on the fly.
See AndroidDebugBridge.determineAndValidateAdbPort() method for more details. While
Drodium allows you to change adbPort for running emulator, it always runs the bridge on
default port 5037.
We need a way how to change this server port in Droidium configuration.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira