Android - adb tcpip error - android

I want to connect to the Android device using adb over the network. I am familiar with How can I connect to Android with ADB over TCP? and with https://developer.android.com/guide/topics/usb/index.html and follow the guidelines. Specifically, I did the following:
# adb kill-server
# adb tcpip 5555
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
restarting in TCP mode port: 5555
# adb connect 192.168.1.101:5555
unable to connect to 192.168.1.101:5555:5555
Due to the last error, I also tried
# adb connect 192.168.1.101
unable to connect to 192.168.1.101:5555
I also tried to restart the device itself, but it did not help.
Any reason why it does not work?
Update: To clear any doubts, I am sure that this is my device internal IP address.

I've been having the same issue with my unrooted device. And contrary to popular belief it seems that adb tcpip <port> requires either an emulator or a debug build or root privileges; at least according to the source code.
master branch: https://github.com/android/platform_system_core/blob/master/adb/adb.c#L898 look at should_drop_privileges which prevents https://github.com/android/platform_system_core/blob/master/adb/adb.c#L966 adb_main to open a TCP/IP socket connection.
In older branches the logic for identifying the privileges of adbd were in adb_main itself. See: https://github.com/android/platform_system_core/blob/froyo-release/adb/adb.c#L860
So, to further prove that adbd won't enter TCP/IP mode (even though adb tcpip gives out no errors), look at the following:
adb shell getprop | grep 'ro.secure\|debuggable\|qemu', output for my device:
[ro.secure]: [1]
[ro.debuggable]: [0]
This does not meet the conditions of being able to get a secure value of 0 in adbd, since I'm not running an emulator (which needs TCP/IP by default), I'm not running a debuggable build of Android, and I'm not root.
Furthermore if you issue an adb shell netstat command you'll see that there's nobody listening on port 5037 or 5555 or whatever else you supplied to the tcpip command as expected from an adbd running in TCP/IP mode.
Hope this helps, good luck!

The ability to restart adbd using tcpip transport can vary from device to device. Without knowing exactly which device you're using it's very difficult to know the exact cause.
I tested "adb tcpip 5555" on a Galaxy Nexus (takju) running 4.2.1 and found it to work. I also tested on a couple other devices and those did not work.
I managed to get it to work using root access on a Motorola Droid 3. Note that ro.secure=1 and ro.debuggable=0 still. I simply by manually set service.adb.tcp.port" to "5555" as such:
devbox:~/droid3$ adb shell
shell#cdma_solana:/$ getprop | grep 'ro.secure\|debuggable\|qemu'
[ro.secure]: [1]
[ro.debuggable]: [0]
shell#cdma_solana:/$ su -c 'setprop service.adb.tcp.port 5555'
shell#cdma_solana:/$ exit
devbox:~/droid3$ adb tcpip 5555
restarting in TCP mode port: 5555
devbox:~/droid3$ adb connect 172.16.0.14
connected to 172.16.0.14:5555
devbox:~/droid3$ adb -s 172.16.0.14:5555 shell
shell#cdma_solana:/$
Although I specified 5555 when running "adb tcpip" it gets ignored by the device. It seems that this particular device does not have the required access to set the "service.adb.tcp.port" property without root.
Similarly, you can go back to USB as such:
shell#cdma_solana:/$ getprop | grep adb
[persist.service.adb.enable]: [1]
[ro.sys.atvc_allow_all_adb]: [0]
[persist.adb.tcp.port]: []
[init.svc.adbd]: [running]
[service.adb.tcp.port]: [5555]
shell#cdma_solana:/$ su -c 'setprop service.adb.tcp.port ""'
shell#cdma_solana:/$ exit
devbox:~/droid3$ adb -s 172.16.0.14:5555 usb
restarting in USB mode
devbox:~/droid3$ adb shell
shell#cdma_solana:/$
The reasons that this might not work on other devices vary.
On the Galaxy Nexus I tested, the shell user is able to set the "service.adb.tcp.port" property. It's not clear why this differs at this time.
Interestingly it seems the droid3 will not continue to listen on USB if you enable TCPIP. However, the Galaxy Nexus will.
Hope this helps..
PS. See also: How can I connect to Android with ADB over TCP?

I also met same scenario as your, TCPIP setup succeseed, but adb connet failed. I finally found it's my network problem, the ping also failed under that scenairo.
After i made the ping works, the adb connect works as well. So, my suggestion is to check your network environment.

Hi there I know this is an old question but I was having the same problem. I am not sure it is the same case for you but the problem for me was that I was connecting my Android device through a USB expansion, as soon as I connected the Android device directly to the USB port in my MAC it worked.
Just to clarify try to connect the Android device directly to the computer or try switching the USB port.

Related

ADB Connection refused from Mac to Android

I am trying to sideload a build to my phone, Alcatel Android 7. I have been able to sideload to it before but it's stopped working when I switched to a new network. I am running it from MacOS terminal.
Courtneys-MacBook-Pro-3:~ courtneytaniguchi$ adb connect 10.0.0.216
failed to connect to '10.0.0.216:5555': Connection refused
Courtneys-MacBook-Pro-3:~ courtneytaniguchi$
This phone is developer enabled, I have allowed installation of apps from unknown sources turned on in security, and USB debugging is on too. Yes, I am on the same network.
I had a similar problem failed to connect to '192.168.31.84:5555': Connection refused, final worked by:
kill and restart adb
adb kill-server
adb start-server
makesure USB wired connected
adb devices can see your device id
re-config to tcpip mode: adb tcpip 5555
Note: for multiple USB connected devices, should specify device serial id:
adb -s device_serial_id tcpip 5555
connect to you device via WiFi: adb connect your_android_phone_ip:5555
Full log for your refer:
 adb kill-server
 adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
 adb devices
List of devices attached
2e2a0cb1 device
orga4pmzee4ts47t device
 adb tcpip 5555
error: more than one device/emulator
 adb -s 2e2a0cb1 tcpip 5555
restarting in TCP mode port: 5555
 adb connect 192.168.31.84:5555
connected to 192.168.31.84:5555
Based on the commands you are entering it seems you are trying to do adb over wifi.
The following may help:
Rebooting the phone
Ensuring the phone is listening over TCP/IP by connecting to it via the USB and entering adb tcpip 5555
Turning USB debugging off and on again
I had the same error. Solved by following extra steps mentioned here which is connecting the device via USB and then executing the following command after finding device id :
./adb -s <device id> tcpip 5555
If you are stuck in the sideloading process, you can always e-mail the .apk file to yourself at an e-mail address which is configured on the phone, download the attachment, then go to 'downloads' app, and click on the .apk file, it should ask if you are sure you want to install the app, just say yes. You have to make sure that you have already selected 'Allow' in the Unknown Sources section in Settings/Development.
Same happened with me. Always rejected, I have two devices used to connect over wifi for some Android Project, im always rejected to 5555 on my Huawei Device. But there is one workaround i know that works.
➜ ~ adb connect 192.168.8.108:5555
failed to connect to '192.168.8.108:5555': Connection refused
➜ ~ adb connect 192.168.8.108:7612
connected to 192.168.8.108:7612
Try port 7612
Thanks!

Trying to setup ADB wireless, stuck at "adb tcpip 5555"

I used to be able to setup wireless ADB no problem (plug in, adb tcpip 5555, adb connect ), now it gets stuck indefinitely during the "adb tcpip 5555" command. Wired adb still works fine, so does setting up wireless ADB through apps in play store, just not via cmd. Between wireless working and now not working, I did a bunch of things so any of them may or may not be the problem:
1) Reformatted computer (Same OS)
2) Redownloaded the SDK needed for Android Development
3) Went from ParanoidAndroid to GPE on my HTC One.
Anyone have any idea what the problem is?
You can emulate what apps do with these steps on your device with root and android terminal emulator:
$ adbd stop
$ setprop service.adb.tcp.port 5555
$ adbd start
Then use adb connect XXX.XXX.XXX.XXX where XXX.XXX.XXX.XXX is your ip address found from:
$ ifconfig wlan0 | awk '/inet addr/ {print $2}' | cut -d: -f2
You can check if your connection is establed using netstat | grep 5555. You should see a tcp entry with your ip address and port for adb connectivity.
If your device is rooted then it is very simple to establish a wireless connection, you don't even need a USB cable. Download this app from Google Play https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb&hl=en
It worked for me at least, and as can be seen from the app rating it works for almost all.
-----Enter the command adb kill-server at command prompt-----
C:>adb kill-server
-----Enter the command adb devices-----
C:>adb devices
List of devices attached
daemon not running; starting now at tcp:5037
daemon started successfully
DeviceID device
-----DeviceID is the unique ID of connected device-----
-----Enter the command adb tcpip 5555-----
C:>adb tcpip 5555
restarting in TCP mode port: 5555
-----will see the response as given above -----
-----Enter the command adb connect 1.1.2.2-----
-----1.1.2.2 is the mobile device IP-----
C:>adb connect 1.1.2.2
connected to 1.1.2.2:5555
-----will see the response as given above -----
-----Now u can use 1.1.2.2:5555 ID as wireless to connect device-----

ADB tcpip command without cable

I need remote ADB shell..
I know that we have to issue "ADB tcpip ".. to change ADB server to TCP listening mode.
But, the problem is that my phone is not rooted, and I do not have USB cable.
I can't issue tcpip command since I do not have USB cable,,
I can't change default.prop file as the phone is not rooted.
Is there any other ways to change ADB server to TCP listening mode???
I found an articel that says you can execute setprop persist.adb.tcp.port 5555 to make tcpip mode autostart after reboot.
The problem is, you must run this command as root.
On my device unfortunally the command su doeas not exist.
Here is the orginal Permanent network debugging on android
EDIT: I discovered, that the su command is only available when your device is rooted.
So the solution only works when you have a rooted phone
The simple answer is: no, you can't.
As you said, you can't access the prop file and don't have a cable to change with ADB. The only way is you find the port via an Android terminal emulator (a.k.a Termux)
For anyone looking for a better answer:
YES, YOU CAN!!
When you try to execute "adb tcpip 5555" without an USB cable, it returns:
"error: no devices/emulators found"
Emulators?? After googling I found the way and made a batch file that connects my device directly through WIFI, no cables needed at all:
set /p ip= Device IP:
:CONNECT
if "%CD%"=="C:\" goto ROOT
cd ..
goto CONNECT
:ROOT
cd ...Android\Sdk\emulator
echo.
echo Starting emulator...
start /MIN emulator -avd Nexus_5X_API_29_x86 -no-window
(you can check other avaliable devices with "emulator -list-avds")
cd ..
cd platform-tools
adb wait-for-device
echo.
echo Emulator started.
echo Connecting with device...
adb tcpip 5555
adb connect %ip%
echo.
echo Closing emulator...
(you need it just to be able to execute "adb tcpip 5555")
adb -s emulator-5554 emu kill
(you can check the name with "adb devices")
To enable wireless debug need to configure the ADB command. (in mac os)
Step1:- First of all need to enable adb command. (check SDK tool and install command-line tools)
Step2:- connect the device with a USB cable after that run the below command.
command: adb devices
the above command will show a list of connected mobiles.
Step3:- after that, we need to configure TCPIP protocol:
e.g : adb tcpip 5556
Step4:- Run command to connect the device.
command: adb connect your_ip:port_address
eg:- adb connect 192.168.1.152:5556
If you are using the stock android os system, then you can enable remote debugging in Settting -> developer options.

Getting Error while configuring ADB

Trying to configure ADB so that I can debug it via wifi, I have checked on Google but not getting proper resolution.
Tell me what to enter in port address, device ip.
Moreover setprop service.adb.tcp.port command is running when i give space between set and prop, bit confuse...
Seeking for help
I got the following article, and wanted help in the same context.
disconnect device from usb then tell it to listen on 4455
adb tcpip 4455
restarting in TCP mode port: 4455
connect to the device using a specified ip:port. my device is using wifi
adb connect 192.168.1.103:4455
connected to 192.168.1.103:4455
now do normal adb commands over tcp
adb shell
when your done, you can put it back in USB mode
adb usb
restarting in USB mode
Help me
These are commands for the shell of the android device, not for the host system.
Type adb shell to get the device's shell and then enter them. If you get back to the windows shell prompt you are in the wrong place.
However those commands may not be effective on a secured device anyway.
setprop is an Android command and is meant to be used in a terminal after su on the device (you can do adb shell setprop ... but when you adb shell stop adbd you'll loose your device connection). The easier way if already connected via USB is adb tcpip 8600 and then adb connect IP_OF_PHONE:8600 -- but this will only work if adb shell will get you a root prompt (starts with # and not $). Be aware that anyone on your wifi network can access your device!

setprop doesn't set the property on rooted Android phone

I'm developing an application (using Eclipse + Android SDk/NDK) which uses the micro-usb port on an android phone to connect to peripherals. I am trying to connect to the ADB daemon on the phone via WiFi (tcp port 5555) so I can debug my application in Eclipse. However, I just can't get this to work.
Nothing I try actually results in the ADB daemon on the phone switching to TCPIP mode (as far as I can tell by looking at the output of getprop). The issue seems to be that I can't set the relevant service.adb.tcp.port property on the phone. The development phone I am using is an LG GT540 running CyanogenMod 7.0.0 (Android v2.3.3). Development machine is iMac running OS X Lion.
Here is some relevant information on what I have tried/confirmed/discovered:
The phone is rooted (ru.secure = 0)
Connecting to ADB via USB works fine
The adb service on the Mac is running as root (adb root)
adb shell gives me a shell with super-user access (# prompt, su, ability to edit system files etc)
adb tcpip 5555 does not complain or throw errors when run from a terminal window on the mac but does not set the service.adb.tcp.port property on the phone
setprop service.adb.tcp.port 5555 entered at the # prompt of a terminal window on the phone does not complain or throw errors but does not set the service.adb.tcp.port property
setprop persist.service.adb.enable 0 works from both Mac and phone shells (confirmed by checking ADB daemon stops and getprop returns 0 for the enable property)
setprop persist.service.adb.enable 1 works fine from both Mac and phone shells (confirmed by checking ADB daemon starts and getprop returns 1 for enable property)
The only properties on the phone relating to ADB on the phone are persist.service.adb.enable and init.svc.adbd (if ADB is running)(confirmed by getprop | grep adb on the phone)
Apps on the market that purport to 'automatically' configure ADB for Wifi (such as WiFi ADB) do not work either (tcp.port property is not set and ADB over TCP does not work)
Am I looking too hard here and missing something obvious? There are many posts and articles on the Internet relating to problems getting ADB to work over TCP but they all relate to phone rooting issues.
Is anyone able to shed some light on why I can't seem to set this particular property or suggest any other issue that may be preventing the ADB daemon from running in TCPIP mode?
You need to stop and then restart adbd on the phone for the tcp port property to take effect.
setprop service.adb.tcp.port 5555
stop adbd
start adbd
With any device (rooted or not) it really ought to be as simple as:
Connect to USB
Run adb tcpip <port>
You will see restarting in TCP mode port: <port> spit out the terminal if it worked. If you see nothing, it didn't.
The property is set for you by the daemon. Tutorials telling you to set the propery and reboot adbd are focused on code that needs to execute on-device (i.e. if you are writing an ADB over WiFi app).
However, you mentioned you are using Cyanogenmod. Doesn't CM have an "ADB over Network" setting in Developer Options (I swear it was there in CM7)? I know that their chosen port is 5555. You may be running into conflicts with that feature trying to do it manually. Probably best to use what's built into the system if it's there.
1 line to add on start of application.
setprop service.adb.tcp.port 5555 && stop adbd && start adbd
This resets adb on start!

Categories

Resources