I\'m using React.JS and when I do react-native run-android
(with my device plugged in) I see a blank page. When I shake the device and select Debug JS Rem
I did @sajib s answer and used this script to redirect ports:
#!/usr/bin/env bash
# packager
adb reverse tcp:8081 tcp:8081
adb -d reverse tcp:8081 tcp:8081
adb -e reverse tcp:8081 tcp:8081
echo "
The other answers here were missing one crucial step for me. In AndroidManifest.xml I needed to add usesCleartextTraffic:
<application
...
android:usesCleartextTraffic="true">
You probably don't want to keep this in the production release of your app though, unless you want to support insecure http requests.
After I added this to my AndroidManifest.xml, then I followed Tom Aranda's answer, and the emulator was finally able to connect to the debugger.
Solved the issue following:
Cmd + M
on emulator screenDev settings > Debug server host & port for device
localhost:8081
react-native run-android
Debugger is connected now!
uninstall your application, then run react-native run-android. then click debugging end in chrome replace http://localhost:8081/debugger-ui/, end run react-native run-android. if you still haven't succeeded try again
In my case the issue was that the emulator was making a request to:
http://10.0.2.2:8081/debugger-ui
instead of:
http://localhost:8081/debugger-ui
and the request was failing.
To solve the issue: Before enabling remote debugging on your emulator, open http://localhost:8081/debugger-ui
in chrome. Then enable remote debugging and go back to the chrome page where you should see your console logs.
In my case, selecting Debug JS Remotely launched Chrome, but did not connect with the android device. Normally, the new Chrome tab/window would have the debugging URL pre-populated in the address bar, but in this case the address bar was blank. After the timeout period, the "Unable to connect with remote debugger" error message was displayed. I fixed this with the following procedure:
adb reverse tcp:8081 tcp:8081
http://localhost:8081/debugger-ui
into the address field of my Chrome browser. You should see the normal debugging screen but your app will still not be connected.That should fix the problem. If not, you may need to take the following additional steps:
react-native run-android