I am trying to use ADB on an Android device itself, so without any host computer. This was working perfectly a couple of days ago, but it suddenly stopped working. As far as I know nothing changed since then (e.g. no apps (un)installed). I could use adb backup -f /sdcard/backup.ab <package-name>
in a terminal emulator and it would start to backup that package. When I try that now, it returns adb: unable to connect for backup
. Investigating using adb devices
returns an empty list. I never bothered to check the devices previously, I just went straight to my adb command, because everything was working.
This was on an HTC Desire running Android 4.4.2, ADB version 1.0.31. Using ADB from my PC with this phone is working perfectly, but this is not what I want.
What I have tried
adb devices
returns an empty list on all of them. I am starting to wonder why this has worked on my HTC Desire in the first place.adb kill-server
+ adb start-server
about a hundred times, as well as stop adbd
+ start adbd
.adb -a devices
-> empty list.adb usb
-> error: device not found
.adb tcpip 5555
returns error: device not found
. getprop
returns no entry named service.adb.tcp.port
and setprop service.adb.tcp.port 5555
silently fails. (Checking afterwards using getprop service.adb.tcp.port
returns nothing. Doesn't this need root?)adb connect localhost
returns unable to connect to localhost:5555
.adb connect localhost:5038
returns connected to localhost:5038
. However adb devices
still returns an empty list, and adb backup
returns adb: unable to connect for backup
. Furthermore adb shell
returns error: device not found
and adb get-state
returns unknown
. So no success here either.getprop dhcp.wlan0.ipaddress
(returns 192.168.1.xx) and then adb connect 192.168.1.xx
returns unable to connect to :5555
. adb connect 192.168.1.xx:5038
-> unable to connect to :5038
. Using ADBHOST=192.168.1.xx adb start-server
has no effect on these outcomes.setprop service.adb.tcp.port 5555
, adb devices
at least shows a device, however offline (namely localhost:5555 offline
). Somewhat near the end of the thread a solution is reached, which involves changing the $HOME directory so as to change where the RSA keys are saved, e.g. HOME=/sdcard
. It is then necessary to append the public key to /data/misc/adb/adb_keys using cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys
. However, I presume this needs root? Also, all of this was not necessary in the working situation so I doubt the solution to my problem is to be found in this direction. This article, derived from the thread at AOSP's Issue Tracker, does not speak of appending the public key. However, the approach mentioned is unsuccessful. netstat
returns (among others):
Proto: tcp
Recv-Q: 0
Send-Q: 0
Local Address: 127.0.0.1:5038
Foreign Address: 0.0.0.0:*
State: LISTEN
ps
shows an /sbin/adbd
process as well as an adb
process:
- USER: shell PID: 92 PPID: 1 VSIZE: 3624 RSS: 264 WCHAN: ffffffff PC: 00000000 S NAME: /sbin/adbd
- USER: u0_a57 PID: 9754 PPID: 1 VSIZE: 3016 RSS: 988 WCHAN: ffffffff PC: 4014f768 S NAME: adb
- (Commands executed from the terminal are executed as USER: u0_a57.)
I guess that's pretty much it.
I am looking for a solution where no root is needed, as it was not needed when I had it working before. I hope my situation and question is clear. Please let me know if my question needs improving, as this is my first time posting on Stack Overflow. Hopefully someone can help me with this. Thanks in advance!
I believe your device might have rebooted. To initially get your phone into tcp, you must have ran adb tcpip 5555
from a computer. But that doesn't last forever. If your phone gets rebooted, then you will have to run adb tcpip 5555
from a computer again.
I am not sure what you meant when you said:
Trying to restart adb(d) in TCP mode is unsuccessful (even though this was not necessary in the working situation). adb tcpip 5555 returns error: device not found.
Did you run that from a computer? If it was from a computer then I'm not sure what the problem is there. But if it was from the phone, then it can't find the device to change to tcp.
To fix this, adb tcpip 5555
from a computer should work.