12

(This question definitely is related to ADB is not starting (no error message) but there is no clear explanation what fixed the issue and reinstalling over and over again doesn't convince me.)

When I run my usual

$ sudo adb kill-server && sudo  adb start-server

I have to CTRL-C it.

the suggested adb_trace álà the other question yields this:

# export ADB_TRACE=all
# adb start-server
system/core/adb/adb.c::main():Handling commandline()
system/core/adb/adb_client.c::_adb_connect():_adb_connect: host:version
system/core/adb/transport.c::writex():writex: fd=3 len=4: 30303063 000c
system/core/adb/transport.c::writex():writex: fd=3 len=12: 686f73743a76657273696f6e host:version
system/core/adb/transport.c::readx():readx: fd=3 wanted=4 <---- freezes here

strace is slightly more verbose and I get this:

# strace /home/leo/Downloads/android-sdk-linux/platform-tools/adb start-server
... many
... many
... lines
futex(0xffab8474, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, f742a700) = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGRTMIN, {0xf77525f0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xf7752680, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=-4286578688, rlim_max=-9223372032703125888}) = 0
uname({sys="Linux", node="donleo", ...}) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(5037), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
write(3, "000c", 4)                     = 4
write(3, "host:version", 12)            = 12
read(3, <---- freezes here

So, what next?

Another observation when trying to fix this issue was that updating the sdk via the sdk manager failed. It tells me that I have Android SDK Platform-tools 16.0.2 and wants to update to 17. Clicking install just hangs forever without doing anything. I assume that both actions indefinitely wait for an answer from the same component. [Update: ] Deleting the component worked. Installing it now showed an issue (in contrast to update which did not show any "red" line in the log) saying that stopping adb does not worked. After killing the adb the update went through but adb still refuses to work.

Update: The suspicion that my installation of adb itself might be broken can be ruled out I guess. I'm using the manual download of the SDK and just tried the adb from the ubuntu repository (4.2.2+git20130218-3ubuntu1) and this hangs at exactly the same spot.

Community
  • 1
  • 1
Giszmo
  • 1,944
  • 2
  • 20
  • 47

5 Answers5

30

Found it. In the style of the very educative comment on a bug report:

~# adb devices
adb.c::main():Handling commandline()
adb_client.c::adb_query():adb_query: host:devices
adb_client.c::_adb_connect():_adb_connect: host:version
transport.c::writex():writex: fd=3 len=4: 30303063 000c
transport.c::writex():writex: fd=3 len=12: 686f73743a76657273696f6e host:version
transport.c::readx():readx: fd=3 wanted=4
^Z          
[1]+  Stopped                 adb devices

Hmm... file descriptor 3?

# pgrep adb
5982
# ls -l /proc/5982/fd/
total 0
lrwx------ 1 root root 64 Jun 14 18:04 0 -> /dev/pts/0
lrwx------ 1 root root 64 Jun 14 18:04 1 -> /dev/pts/0
lrwx------ 1 root root 64 Jun 14 18:04 2 -> /dev/pts/0
lrwx------ 1 root root 64 Jun 14 18:04 3 -> socket:[96863]

socket 96863?

# lsof | grep 96863
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/leo/gvfs
      Output information may be incomplete.

adb       5982            root    3u     IPv4              96863       0t0        TCP localhost:55463->localhost:5037 (ESTABLISHED)
# netstat -antp | grep LISTEN | grep 5037
tcp6       0      0 :::5037                 :::*                    LISTEN      2419/java       

ava? java what?

# ps -Alf | grep java
1 S root      2409     1  0  80   0 -  4620 hrtime 16:20 ?        00:00:07 /opt/traccar/bin/./wrapper /opt/traccar/bin/../conf/wrapper.conf wrapper.syslog.ident=traccar wrapper.pidfile=/opt/traccar/bin/./traccar.pid wrapper.name=traccar wrapper.displayname=traccar wrapper.daemonize=TRUE wrapper.statusfile=/opt/traccar/bin/./traccar.status wrapper.java.statusfile=/opt/traccar/bin/./traccar.java.status wrapper.script.version=3.5.19
0 S root      2419  2409  0  80   0 - 810286 futex_ 16:20 ?       00:00:41 /usr/lib/jvm/java-6-oracle/jre/bin/java -Djava.library.path=../lib -classpath ../lib/wrapper.jar:../tracker-server.jar -Dwrapper.key=ja2Mz5xiI18XmG4C -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.disable_console_input=TRUE -Dwrapper.pid=2409 -Dwrapper.version=3.5.19 -Dwrapper.native_library=wrapper -Dwrapper.arch=x86 -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 org.tanukisoftware.wrapper.WrapperSimpleApp org.traccar.Main /opt/traccar/conf/traccar.cfg
0 S leo       3549  3421  2  80   0 - 853194 futex_ 16:24 ?       00:02:59 /usr/bin/java -Xms40m -Xmx512m -XX:MaxPermSize=256m -jar /home/leo/Downloads/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar -os linux -ws gtk -arch x86_64 -showsplash /home/leo/Downloads/eclipse//plugins/org.eclipse.platform_4.2.2.v201302041200/splash.bmp -launcher /home/leo/Downloads/eclipse/eclipse -name Eclipse --launcher.library /home/leo/Downloads/eclipse//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120913-144807/eclipse_1502.so -startup /home/leo/Downloads/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar --launcher.overrideVmargs -exitdata 148007 -vm /usr/bin/java -vmargs -Xms40m -Xmx512m -XX:MaxPermSize=256m -jar /home/leo/Downloads/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
0 S root      6280  4662  0  80   0 -  2360 pipe_w 18:24 pts/0    00:00:00 grep --color=auto java

grrrrr! Why? Why? Why is there no timeout or something in adb? Why does traccar – a software that also has an Android client – use ADB's port 5037 for its IntelliTrac component? They use all ports 5000 through 5040.

# /etc/init.d/traccar stop
Stopping traccar...
Stopped traccar.
# adb start-server
# adb devices

List of devices attached 
016814F11001F009    device
Giszmo
  • 1,944
  • 2
  • 20
  • 47
  • 7
    I filed that bug report. :) – Gardner Bickford Jul 25 '13 at 17:32
  • I wonder how you found this SO of me talking to myself!? Anyway thanks for your post. Wish I could finally remember the commands used here but I know I have to google them every time. (as nobody else was involved, I guess it's ok to answer your kind of off topic post with some off topic reply.) – Giszmo Jul 25 '13 at 21:39
  • Wow you are a genius. I had this issue on a Mac. I do not know if Traccar was the cause, but there was some process on that port. I killed the process and was able to work – orellabac Mar 24 '15 at 03:14
  • So what's the solution to this problem? – IgorGanapolsky Apr 13 '16 at 22:20
  • 1
    @IgorGanapolsky if you are affected by the same problem, make sure you don't have another process on the same port. `adb` will silently wait for the port to be available. (At least that was the case 3 years ago) – Giszmo Apr 14 '16 at 16:29
  • 1
    wow! excellent I had this issue on my mac and it took me days to find what it was. – orellabac Jun 11 '16 at 12:34
  • 1
    Here we are in 2020, exactly the same issue. Been debugging this intermittently for the past few days. Thanks for your help! – Devin Norgarb Aug 11 '20 at 10:27
  • 1
    Just installed Traccar server 2 days ago, and been scratching my head ever since. Thanks mate, I genuinely think this SO post should go in Traccar's documentation page – Samuel Adam Mar 19 '21 at 09:55
17

Thanks for your solution.

But I tried to kill the adb process and I can able to restart adb process.

1) find the PID of adb

#pgrep adb
23038

2) kill adb process

#kill -9 23038

3)List the devices

#adb devices
Pranav Singh
  • 17,079
  • 30
  • 77
  • 104
Rajesh M
  • 191
  • 1
  • 3
0

AndyOS (Android Emulator) also conflicts with ADB. Killed the Andy service and adb started working again.

Bill Calderwood
  • 111
  • 1
  • 4
0

Following the answer by giszmo, my adb was blocked, but not by another program, but by a connect for an IPv6 socket [that was never going to bind].

ipv6.disable_ipv6=1

On my kernel resolved the issue, but probably isn't a permanent solution.

hiddensunset4
  • 5,825
  • 3
  • 39
  • 61
0

One simple solution I have found is, disconnecting the PC from the internet and then restarting the computer. Once the system reboot is completed start Android studio without the internet connection.

Once the Android studio is up and running, connect the computer to the internet.

This is the only solution that worked for me.

shafeeq
  • 1,499
  • 1
  • 14
  • 30