When to use adb connect with localhost? - android

I have one emulator set up locally
$ adb devices
List of devices attached
emulator-5554 device
When I do adb connect localhost:5555 I will have 2 devices set up
$ adb devices
List of devices attached
emulator-5554 device
localhost:5555 device
How is that possible? This is still the same device, right? Available only under two different names.
In what situations running adb connect localhost:5555 make sense? I've seen plenty of posts on SO doing that, but what they have emulator available locally?

Related

ADB devices list empty with wireless debugging

I have Android 11 on my phone, I have setup Wireless Debugging, and in the list of Paired Devices my computer shows up. However, when I run adb devices -l on my computer, the list of devices is empty.
Why am I seeing an empty list. Is there something extra that I need to do?
Here is the device:
Here is the terminal:
You will need to connect to the device before it becomes visible in adb devices -l. You must run adb connect ipaddress:port, in your case adb connect 192.168.1.123:37457. Docs
It says unknown command adb pair
Saw the help there is no pair command listed in the menu
Instead go to platform-tools folder in my case ~/Android/Sdk/platform-tools from here you can execute ./adb and then in the help you can see there the pair option
./adb pair <ipaddress>:<port> will prompt for pairing code
Then you are sucessfully connected

android - adb more than one device/emulator

I genymotion emulator and my phone connected , I want to run and debug my application over wifi , I found the instruction to do so but I get this error when I enter this code :
adb tcpip 5555
I get this error :
error: more than one device/emulator
How can I make my device as default or something like that to solve this problem ?
You can send commands to a specific device, according to docs:
$ adb devices
List of devices attached
emulator-5554 device
emulator-5555 device
$ adb -s emulator-5555 do_your_command
Also, if only one is emulator or a real device you can just attach -e or -d and send the command to it:
If you have multiple devices available, but only one is an emulator, use the -e option to send commands to the emulator. Likewise, if there are multiple devices but only one hardware device attached, use the -d option to send commands to the hardware device.
Do following thing which will help you,
You getting the message just because you are connected more than one device.
Run commands
adb devices
after the fire above command, you get the list of the device, From the list select your device id which not emulator
and fire following command
adb -s f725aa8b7ce4(deviceId) tcpip 5555
and after this fire
adb connect yourIp 5555
I was struggling with same issue since months, later while testing in postman I got know that "Appium inspector" is the main reason for this issue. As it creates new session Id and interrupt the running framework server.
Hence, adb kill-server adb start-server resolves the issue as it actually kill the session ID created by Appium inspector and starts new server.

Android device adb another device

Does anyone know how to make a device adb another device.
i.e
Device1 I create a folder apks and copy and paste 5 apk files.
then I use micro usb to micro usb to connect to another device.
then from device1 i adb all these 5 apk files to device2
using something like this a guess ?
adb install 1.apk & adb install 2apk & adb install 3.apk & adb install 4.apk & adb install 5.apk
I know this is possible as I know someone who does it. But their won't reveal how it is done. Thank you
AFAIK, connecting two android devices via USB is meaningless.
You can use adb over tcpip (over WiFi) in order to accomplish this.
Here is what you need to do:
Make sure both devices are on the same network. This can be done by connecting them to the same AP, by peering them together using WiFi direct or
by setting one of the devices as a hotspot and connecting the second to it.
Configure device 2 adbd to work over tcpip (this is done from your desktop shell):
adb tcpip <port number>
From device 1 shell run:
adb connect <device 2 ip>:<port number>
adb install 1.apk
adb install 2.apk2
and so forth...

ADB shell-ing to wifi connected device when usb device present

I have two devices connected to my workstation simultaneously, one by usb, the other over wifi.
C:\>adb devices
List of devices attached
Cxxxxxxxxxx2 device
192.168.60.69:5555 device
I'm not sure how to shell into the wifi connected device while the usb one is present.
I've tried the following
C:\>adb shell
error: more than one device and emulator
C:\>adb -s 192.168.60.69 shell
error: device not found
C:\>adb -s 0xxxxxxxxxxxxxx1 shell
error: device not found
where 0xxxxxxxxxxxxxx1 is hardware id of wifi connected device
Only way that works is to disconnect the usb connected device. However, I'm going to eventually have multiple wifi connected devices, I still don't know how to distinguish between them when trying to shell in?
Edit (6/13/2014)
I see why I was omitting the port, b/c the connect command returns the following error when trying to connect and cannot (say for instance the devices wifi was accidentally turned off)
C:\>adb connect 192.168.60.69:5555
unable to connect to 192.168.60.69:5555:5555
This made me think that adb would append port based on ip. However this is not the case, since after wifi was enabled on the target device, the above command did work
C:\>adb connect 192.168.60.69:5555
connected to 192.168.60.69:5555
I needed to mention something to show that I atleast know tcp/ip connect fundamentals (ip and port). Kinda embarrassing...
Try:
C:\>adb -s 192.168.60.69:5555 shell

List adb devices on network

I have a few devices enabled for over the air debugging. Is it possible to list the adb devices on the network? Something similar or to the same effect as adb devices but for devices that are enabled for over the air debugging.
If you do these steps exactly and run the adb devices command, the android device should appear under the List of Attached Devices. First open a command window and make sure you are either in the same directory as adb or have adb in your PATH variable. Then execute the following list of commands:
$adb usb
restarting in USB mode
$ adb devices
List of devices attached
######## device
$ adb tcpip 5555
restarting in TCP mode port: 5555
Get the IP address of your android device. (Usually under System settings then Network settings, you can look up how to get the IP address on your specific device). The IP address should look something like 12.34.56.78 (this could vary though). Once you have the IP address continue with the following commands:
$ adb connect 12.34.56.78
connected to 12.34.56.78:5555
Remove the USB cable from the device
$ adb devices
List of devices attached
12.34.56.78:5555 device
Source
That's not possible with the Android SDK, as it would involve a huge network scan without any clue, just blind-pinging port 5555 of every possible address on the network.
But probably you can do it with a network scanner that looks for port 5555 open.

Categories

Resources