To solve the problem of the red screen when trying to reload our application we should do the following.
We must upload the node service on a separate port through the command " react-native start --port=8088
", but at the moment of setting up our mobile we have a particularity.
Obs0: Do not close the terminal that is running your service on the new port , to execute the commands below, open another instance of the terminal.
Since we can not press any key on the phone, we should send the command " adb shell input keyevent 82
", this will simulate Ctrl + M (used to open the menu if you are using the Android Studio emulator) and open the options menu.
With the menu open, choose " Dev Settings " and then click " Debug server host for device ". Now the particularity. Run the " ipconfig
" command and retrieve the IPv4 value, with that value in hand, type the value of your IPv4: your port ( ex: 123.235.0.13:8088). Remember that the port must be the same as the one that was started by the " react-native start " command. Soon, with that done, your cell phone will be able to reload using the RR.
If you are using the emulator, just follow the same steps, without using the " adb shell input keyevent " command and at the time of entering the IP, use the following IP: 10.0.1.1: [port_cropped] or 10.0.2.2:[port_cropped], which in our case was port 8088 , then it would look like: 10.0.1.1:8088 or 10.0.2.2 : 8088
Obs1: If it does not work using ip 10.0.1.1 or 10.0.2.2, use IPv4 even in the emulator.
Obs2: To simulate the RR command, simply execute the command " adb shell input keyevent 46 46
" in the terminal.
Obs2.1: If an error occurs, try again, sometimes the connection may be lost.
Obs3: Official documentation that helped me in the solution: link
Obs4: The cell phone must be connected to the same wi-fi network as the computer.
Obs5: This problem occurs with people who already have their port 8081 compromised by some service, and for some specific reason, they can not stop it. (Ex: McAfee )
Note: All commands mentioned above must be executed in the root folder of your project.
I hope I have helped.
A hug!