ADB - Using adb CONNECT command - android

I'm trying to make a tool that connects to your android phone wirelessly with the connect command.
I know the command and how to set up the ports, the problem is that you have to enter your ip manually. If i want it to be a tool, it should automatically connect to the right ip for the user's phone.
I've tried using localhost to connect
adb connect localhost:5555
But that does not work. If this is possible, please write a comment!
I'm sorry if i didnt explain it properly. English is not my main language.

You're not entering the command correctly. You should be connecting to the device's ip. adb connect [deviceIP]:5555.

Related

ADB auto detect port for adb connect

Everytime I want to connect my adb server to my device, I need to explicitly give the port.
adb connect localhost:<port>
On my case, the port is randomly defined so I have to find it on the interface.
I try to netstat my computer but the port does not appear, except if I adb connect, and just a moment after I adb disconnect. But then it disapear again.
An other thing I thought was to brut force all ports but it takes like an ethernity..
If you have a suggestion I would be glad to read and test it.
Thanks

Connect Android to Computer by Adb Tcp:Ip

i have made an app to share your monitor to your android device by wifi, it works very well.
So i wanted to put as an option to share by usb.
I have found in many websites, the adb tcp connection.
If someone could explain me.
How i can implement such thing.
What i tried so far was:
adb forward tcp:port tcp:port
adb connect ip
No sucess.
Make your app run a server. Run the server on some port e.g. port no. 5749. Send the data thru the server then do adb forward tcp:5749 tcp:5749 and abd connect phoneIP
By the help of these website, I understood how to Connect Tcp via Usb without using Wifi.
So what i wasn't understanding was:
º1 to connect via adb, the android device can only be the server. (otherwise it wasn't working.)
º2 you are going to connect to the localhost (i will explain it better after.) so no need of any wifi ip.
So what i did was:
1º Android: start the server to listen to any connection at PORT (Connect by Usb)
2º PC: use adb, something like:
"shell adb.exe forward tcp:PORT tcp:PORT"
3º PC: try to connect to the server of your android device by the ip which is now "localhost" and your PORT
Then in the code i just redirected the client of the computer as an android device, and handled the server as a normal socket. (Kinda hard to explain myself.)

Android TV ADT-1 adb connect port changed?

Hi as of yesterday I was able to build and push apk files to the ADT-1 Android TV device via WiFi. Then the device had an update and now I'm no longer able to connect to the device. I think the port number adb is allowed to connect on has changed... but to what?
Yes I've made sure the IP address is valid and am using the port number 4321. Pinging the device works. But its giving me the error:
unable to connect to 10.0.0.86:4321:4321
I've tried to connect via ethernet and WiFi. Both fail.
I directly hooked it up to a laptop and manually forced it to use port 4321 again via: "adb tcpip 4321"
Now I can connect with my main dev computer from across the room again.
Grumpf. Look like they removed the necessary "service.adb.tcp.port=4321" from build.prop in 5.0.2.
Why, oh why?

How to use adb over Mobile AP (Portable wifi hotspot)

First : I know about abdWireless app. But my problem is different.
I am using my Android mobile as Mobile AP (Portable WiFi hotspot) for using internet on my computer. I want to use adb in wireless mode but the problem is - when i enable Mobile AP on my android mobile WiFi gets turned off and i am unable to use abdWireless app.
I want to use both wireless ADB and Mobile AP at the same time.
Is there any way to do it ???
Developers have created apps for this:
https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb
Once you start this app, you can connect to your phone like this:
adb connect ip_address_of_the_device
However, your phone must be rooted!
Please let me know if this helps!
On mac:
You need to run: ifconfig
Followed by run: arp -a
In my case, the first listed IP is router IP, ie. IP of your android device with hotspot(let it be: ip_address_of_the_hotspot_device).
Then run either: adb connect ip_address_of_the_hotspot_device or adb connect ip_address_of_the_hotspot_device:5555

adb logcat on a real phone using tcp/ip

Can I dump logs from an android phone over wifi (using tcp/ip) using adb? adb connect can be used, but it needs some server to be running on the phone (at 5555 port). How do I start this server?
Or the only way to get logs from a phone is by connecting it as a USB device?
Install adbWireless on your phone. Run the application and click on the big button (you cannot miss it!). It will activate ADB over Wifi and display the URL to use to connect to it with the adb command.
On your computer, run the adb command with the connect parameter. The usage for adb says:
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.
Obviously the computer and the smartphone must be on the same Wifi network.
zero4
All you are trying to do is drop adb logcat command on the device & send output stream to a remote location. I would suggest, read this post about how to run shell commands in your app.
The summary is
Run "adb logcat"
Collect Output Stream of the command in a file on device
& Finally post that file to your local server OR Manually pull that file from device
The post contains link to everything you are looking for.
Android is very paranoid when it comes to network access. Without root access, you can't really run any servers, just clients. In short, without root, look at the answer from 100rabh.
If you do have root, you could either open up your network stack for incoming connections on port 5555, or you could hack adb to do the inverse connection (that is, connect to your client). The latter is way more secure and shouldn't really be to hard to do. (I haven't looked at the code for a while, though.) The communication bits for all parts of adb is handled in one and the same library, for all three parts of adb (server, daemon and client).
By the way, what you refer to as a server on the phone is really the adb daemon.

Categories

Resources