Debugging React Native over adb tcpip
Asked Answered
D

1

12

I'm trying to attach a USB device (using USB OTG) to my Android device while developing an app using React-Native. Classically to debug an Android app, one connects using USB debug mode over adb, but since my USB port is being used for my USB OTG device, that's not possible.

I tried to use the adb tcpip method (How can I connect to Android with ADB over TCP?) but that doesn't work because my device can't find the 'development server'. Has anyone had any luck debugging this way?

Disunite answered 6/7, 2017 at 22:19 Comment(7)
is the USB you using came with the mobile or you purchased it from a different vendor ?Haggis
(note sure that's relevant, but i'll answer anyways) I can debug over USB just fine with all the cables I use. The problem is when I need to use the phone's USB port to test another USB peripheral (e.g., keyboard or mouse). Debugging requires the phone to be in USB guest most, while when connecting a peripheral it needs to be in USB host mode (see USB OTG), which prevents me from using a USB hub to get more ports. If I can debug react native over TCPIP that would free up my USB port.Disunite
ok, sorry I dont have much knowledge of USB OTG but I myself debug my RN app over wifi n/w (though initially I had to install apk to the mobile which you can easily do it manually ) . Then you can set your ip address in dev settings . Also I want to know which OS are you using?Haggis
no worries. The TL;DR of USB OTG is that your phone can be a USB host and you need a special $2 adapter. Now you know as much as me ;-)Disunite
Interesting. So you basically followed the these directions (#2605227) and it worked for RN? Or did you do someting special? What version of RN? I'm on Mac OS El Cap. React Native 0.45.Disunite
I forgot to tell one thing: I was not running the app using react-native run-android command (though initially I did that for building apk) .I am using npm start .RN v0.46.1 and I am on windowsHaggis
Not sure how react native works, but if you install the apps over usb debugging, adb tcpip followed by adb connect to your phone's IP would make the phone work just like if it was connected (with respect to usb debugging)Beneath
P
7

Make sure your phone and the PC used for development are connected in the same LAN. From the Rage Shake menu (shake the device while your app's screen is active) you should be able to navigate to Dev Settings > Debug server host & port for device which lets you enter the IP & port of the development server for loading from the packager.

Pegmatite answered 19/7, 2017 at 18:28 Comment(1)
That did it! Thanks!Disunite

© 2022 - 2024 — McMap. All rights reserved.