How do I get the TCP port number for a usb connected android phone. I can do this
netstat -an |find /i "listening"
but then it lists all the listening port, how do I know to which port my phone is listening to. anyone on this pls?
Perhaps I am misunderstanding what you are trying to do here but if your phone is connected via USB then it does not have a TCP port open it is addressed via the USB device. Take a look at the AdbTest example program provided with the API.
You can get Adb to connect over wifi (see bootom of this page) but I believe that in most cases this requires a rooted device.
Related
How to get adb logs via bluetooth?
need to connect an android device to my laptop to get the adb logs, but through usb cable its not working.
Dude, you don't need Bluetooth to do so, you can get ADB logs via Wi-Fi.
The steps:
Connect your device to your laptop via USB (yes, you've read right, if your USB cable is not working, you can use an alternative USB cable temporarily or borrow one from your friends).
Type adb tcpip 5555 in the terminal
Type adb connect XXX.XXX.X.X (the X's represent the local IP address of your mobile device, if you don't know your device's IP, go to Settings > Wi-Fi > Advanced).
You can disconnect your device from your laptop and now you can debug your apps wirelessly.
If you really need Bluetooth to use ADB. Bad news! That's not even possible.
I have successfully managed to install the Android Things Dev Preview onto my Raspberry Pi.
I have a problem though. When I first started installing my own applications I was able to connect to the Raspberry Pi through Ethernet, because it displayed the IP address on the TV when I booted up the Raspberry Pi.
Now because I have the Raspberry Pi already running an application, when I boot it up, it is automatically booting into my application without showing the initial screen with the IP address (and I forgot my IP address 🤔).
Is there an easy way to get the IP address of the Raspberry Pi, or connect to it when I don't know the IP address? Even a command to get a list of all available ADB devices on the network would help.
It would be great if when connected to a certain Wi-Fi, you could run something like:
adb network devices
Which could give a list of ADB devices on the network you are on.
The Raspberry PI Automatically broadcasts Android.local and should resolve to the IP address assigned to your Pi on port 5555.
Running the following:
adb connect Android.local
The command above is effectively the same as running:
adb connect <ip-address>:5555
Note: This will only work if your host platform supports multicast DNS service discovery.
This information was found in the documentation here by step 7 https://developer.android.com/things/hardware/raspberrypi.html
You can scan your network for points with ports 5555/5554 open, for example,
nmap -p 5555,5554 192.168.0.2-100
will scan in range 2-100 for any IP addresses with those ports open.
Or you can check in your router which devices are connected
On OS X you can scan for all devices that publish itself as Android.local
dns-sd -Q Android.local
I believe you need Bonjour on Windows/Linux to get something similar, but I'm still not familiar with them.
After figuring out the correct IP for the desired device you can connect as usual:
adb connect <ip-address>:5555
If multicast DNS is not supported on host platform and you have access to your router, you can simply log into it and view the list of connected devices.
You will be able to view all the devices no matter if mDNS is available or if there are any ports opened on the device (or if you don't know which port is opened).
The easiest way how to get to the initial screen with IP address from your application is to connect a USB keyboard to your Raspberry Pi then pressing escape key once :)
I had the very same problem recently and the easiest way in my opinion is that to just install a simple app on your phone (in my case Fing) that shows all the connected devices to your local connection including th RPI with their ip address. So then you are good to go!
I am currently using an API 18 (Jelly Bean) device, and it does not support ADB over Bluetooth by default (No option available in developers option for wireless debugging) I have to connect my device with my Laptop using Bluetooth Personal Area Network which is Bluetooth tethering of my phone. Can anyone help me with starting a TCP open port my phone so that I can connect ADB using the adb tcpip "open_port_no" and adb connect <phone_ip_address>:open_port_no commands?
I have already tried some apps from playstore to do so but they all failed.
You need to enable the TCP port first by connecting a USB cable to your phone and setting it from the console on your PC/Mac:
adb tcpip 4455
Now turn on the Bluetooth on your phone and enable tethering.
You need to use the IP address of your phone. It will most likely be 192.168.44.1 since this is the default. If not:
You can get this using a few methods depending on your computer type:
ifconfig
ipconfig /all
route | grep default
Then connect to your phone from your computer using:
adb connect 192.168.44.1:4455
You should get a response:
connected to 192.168.44.1:5555
This works perfectly for me. Sorry for the late response :) I was just looking for the same thing and happened upon the solution. Sharing is caring.
My PC and Android TV device are in the same net section,so I can use adb connect the debugging device.Also ,I use adb devices command,it shows device on work.But when My PC and device use the same vpn based on the previous internet,I try to ping the device IP,it worked,then I use adb connect the device,it shows connect,but when input adb devices command , it shows device offline. I'm sure the error can't be caused by adb version,for it can work when disconnect the vpn.who can help me? I'm very appreciate for that.
If your PC and device are on the same LOCAL network, all you need to do is find the local IP address of the device (something like: 192.168.xx.xx). Then type:
adb disconnect
adb connect 192.168.xx.xx.
It'll connect again. Works for me.
The only time it does not work is when the device is the one providing the LOCAL network, e.g., your phone's mobile Hotspot. Using a VPN like this does not work directly. Whenever you use a VPN and try using ADB for a mobile hotspot (and the hotspot device is the one you're trying to connect to), you'll realize that the device goes offline.
This is because when you enter "adb connect <REMOTE_HOST>", your PC tries to route your device IP (REMOTE_HOST) via the VPN network, which will not be accessible since your ISP does not allow inbound connections to your device.
An alternative option, which I use for my device (Phone), is to use a wired connection to my PC via a USB cable. It might work for the Android TV if the proximity b/w TV and your laptop is not a problem.
Another alternative (supposing you're trying to connect a phone/Android TV) is to use another phone or router to create a hotspot. Then connect both your PC and phone/Android TV to the hotspot. Find the phone/Android TV IP address 192.168.xx.xx and enter:
adb connect 192.168.xx.xx.
I have an android device which I want to connect to using ADB. For reasons that don't matter here I need it to have an ethernet connection, not wifi. The device itself refuses to have both ethernet and wifi connections at the same time.
I have been using a third party app called ADB WiFi to connect to it with ADB when it is in WiFi mode, and I have found that I can connect to it in wifi, then switch the device into ethernet, and then reconnect to the new IP, and it works.
I would dearly like to be able to connect to my device (which is often remote and hard to reach) without first switching it into wifi and back, to which end I have written my own little app which uses SU and does:
setprop service.adb.tcp.port 5555
stop adbd
start adbd
It says that it is working when I run it and produces no error messages, but I can't connect afterwards. It doesn't work in wifi mode either. After setting up a connection once using the 3rd party app, I can then use stop adbd to prevent adb working, and I can use my application above to enable it again, without wifi or 3rd party intervention, which suggests that it is doing what it thinks it is doing, but missing a one off step.
Does anyone know if there is another thing that must be set / enabled / poked in order for adbd to work? Does anyone know what I'm missing?
Thanks
Have you tried this:
adb tcpip 5555
adb connect 192.168.1.1:5555
replacing the 192.168.1.1 with your phones IP Address?
I was able to get both ADB (through USB) and Ethernet, but it was device specific. I used the Asus Transformer Pad TF701T with the keyboard dock. The dock allowed me to connect the ADB cable and provided a full size USB port. I connected a compatible USB to Ethernet adapter to get Ethernet.