Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adb reverse tcp not working on android connected remotely

Tags:

android

tcp

adb

I am trying to execute reverse tcp command on a android device connected remotely(using adb connect <ip-address>). But I am getting following error while executing:

adb -s 192.168.0.101 reverse tcp:8081 tcp:8081
error: more than one device/emulator

but I have only one device connected.

adb devices
List of devices attached
192.168.0.101:5555      device

same command works fine if I connect my device using usb. Any Ideas ?

like image 961
mchouhan_google Avatar asked Sep 10 '17 08:09

mchouhan_google


People also ask

Can't run adb reverse command failed?

You can click the device option button, or if it doesn't exist for your device use adb shell input keyevent 82 command and select Dev Settings from menu, and then from the section DEBUGGING choose Debug server host & port for device and enter your PC's IP (you can find your IP from ipconfig command for Windows) for ...

How can I connect to Android with adb over TCP?

Steps for connecting the Android with ADB over TCPConnect your android device with a laptop/pc using a USB cable. Then in the android device turn on developer options from settings, and in developer options turn on USB Debugging (PTP/ MTP).


2 Answers

I just came across this, and while none of the answers worked I eventually got it working repeatably. Following these steps should get you wirelessly debugging your React Native app on your real Android device.

I ran adb kill-server && adb start-server first. I'm not sure if that's strictly necessary.

  1. Connect your phone and computer to the same network
  2. Connect your phone to your computer via USB
  3. adb tcpip 5555
  4. adb reverse tcp:8081 tcp:5555
  5. adb connect YOUR.PHONE.IP.ADDRESS:5555

You can find your phone's wifi IP address from Network Settings -> Wifi -> Wifi Preferences -> IP Address.

  1. Disconnect the USB wire.
  2. If the app isn't yet installed, install the app on your phone the way you usually do over USB, react-native run android for most cases.

Open the app, and you get an “Unable to load Script” error. Pressing ‘Reload’ gives an error “Could not connect to development server.” Overcome your despair and push onwards.

  1. Open the developer menu (shake the phone with your React Native app open) and select “Dev Settings”. Select “Debug server host & port for device” from the menu. Find your computer’s ip address. Enter that in the window on your phone, followed by the port number 8081: YOUR.COMPUTER.IP.ADDRESS:8081
  2. Now shake and reload.  Sometimes this doesn’t do anything, so closing the app and reopening does the trick.

At this point, you should see the bundler loading up with the familiar green bar.

  1. shake and hit “debug js remotely”.

From here you should have your normal debugging experience, minus the wire.

like image 164
Lazer Porter Avatar answered Sep 28 '22 03:09

Lazer Porter


I found that if I'm doing a TCP/IP connection, I need to set the reverse command before I connect to the remote device

Example:

adb tcpip 5555
adb reverse tcp:8081 tcp:8081
adb connect 192.168.1.113

If I connect before performing the reverse, I would always get the error about multiple devices/emulators

like image 29
ainesophaur Avatar answered Sep 28 '22 05:09

ainesophaur