Can't connect to standalone React Native Debugger - react-native

I've been having trouble getting the standalone React Native Debugger to work. I'm running an expo project and testing on android device. When I select Debug Remote JS, it opens up http://localhost:19000/debugger-ui/ in my web browser each time. My standalone debugger on port 19000 just says Waiting for React to connect. Not seeing any errors anywhere.

Make sure the device is connected via adb
adb devices
if you see your device, please run this command
adb reverse tcp:8097 tcp:8097
and restart your debugger

Related

Flipper: Hermes debugger cannot connect error: "Debugging connection was closed"

I have downloaded and setup flipper desktop on my windows machine and I am able to run all its features properly including react devtools but somehow hermes debugger doesn't work and shows error message "Debugging connection was closed".
I am using react 16.13.1 and react-native 0.63.2 and I am running app on Samasung Galaxy Note 10 device. Tried multiple thigs suggested by people on internet but nothing seems to work.
Please refer below image
Please help me out.
Start your project with this command:
react-native start --host localhost

No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB

React Native app debug on real device has some problems;
My metro bundler console gives warn:
warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
warning and that cause real IOS device connection problem.
When I try to reload my react native app from Chrome React Native Debugger, it gives above warning and I can not debug my code from on Chrome
react-native: 0.62.2,
IOS: 13.6
It happens on Real device connection. When I work with IOS simulator, there is not problem.
NOTE: My phone and macbook on SAME wi-fi network.
So problem is not related to different wi-fi network usage.
⚠️ For iOS users :
Check that your build target is Debug :
Xcode Product => Scheme => Edit Scheme => Debug (and not release ! )
⚠️ For Android users :
I have found a solution that I posted on github.
Not the best but it could be useful:
First, you have to open MainApplication.java
and remove import com.facebook.react.BuildConfig;
Next, follow these steps :
# Reset metro bundler cache :
`npx react-native start --reset-cache`
# Remove Android assets cache :
`cd android && ./gradlew clean`
# Relaunch metro server :
`npx react-native run-android`
And see the magic 🎉
See here :
https://github.com/facebook/react-native/issues/29396
Running this worked for me for a Physical Android Device.
adb reverse tcp:8081 tcp:8081
or
npm run android-connect
If you face an error saying 'More than two devices are running', make sure that the emulators like BlueStacks are not running.
Your iPhone has to be connected to the same network (WiFi for example) as your Mac, because they have to communicate with each other (React Native Doc).
If it's already the case, then fill in the DCHP server manually on your iPhone and Mac, using Google's server (8.8.8.8), because it could be due to DHCP problems.
You may need to disconnect and reconnect to your Wifi.
For me I need to set the bundler location in my app from "localhost:8081" to "192.168.1.XX:8081" which is my computer's local IP address where Metro bundler runs on and the port is 8081.
If you don't know which port your bundler runs on you can specify it as a parameter like:
npx react-native start --port 8081
Then you need to specify the location in your development app. To do that:
Shake your device
Click change bundle location (I am on RN 0.64 it may differ in yours)
Give the bundler location of your computer's IP and port where Metro bundler runs on like:
and they started to communicate with each other.
My problem was that I was not connected to the same WiFi on my Mac and Iphone.I turned the wifi off and back on on both devices, and made sure both the mac and Iphone was connected to the same WiFi. Annoying, but true!
Your iPhone & mac must be connected to the same network. If both device connected to same network you must check local network availability for your app. (this happened to me on a iOS 14.0 running device).
check local network - iOS 14
Settings -> Privacy -> Local Network
On Android, this may also happen due to a problem with the network security config. If you do use the network security config, try removing the line android:networkSecurityConfig="#xml/network_security_config" from AndroidManifest.xml
My problem was that the emulator I was using had airplane mode turned on (because I tested related functionality). The problem resolved when I turned it off, thus enabling network to operate as usual.
My problem is that the device is not connected to the internet. Throws the error. Try connecting stable internet connection.
When I remove network_security_config.xml and remove the following:
`android:networkSecurityConfig="#xml/network_security_config"`
It works
I work on IOS environment, testing on an IPad that is USB connected.
I managed to fix this issue by adding the bundler address (127.0.0.1) in the ipad to reconnect
Shake the device (opens react native debug menu) > Configure Bundler > "127.0.0.1" in the first field
Hope this helps someone !
What did the trick for me was the following:
In Xcode go to Debug/Detach from YourAppName
Then reattach it by going to Debug/Attach to Process, select your app from the list (usually the first entry at the top).
I tried everything and after running
adb reverse tcp:8081 tcp:8081
yarn android
it worked.
What worked for me in this scenario was these steps
run server with --reset-cache
run npx jetify
open the project in adroid studio
go to refactor -> Migrate to AndroidX (this was the step that i was missing earlier)
start your emulator
run the app from android studio and it should work
Sometimes it's a firewall / router issue - see if that's your problem:
Find out the local IP address of your computer (where your Metro bundler / server is running).
Open a browser from your phone.
Open the IP address from #1 with port 8081 (e.g. http://192.168.0.42:8081).
If it's not loading -> it's a firewall / router issue.
A simple solution would be to connect the computer to the phone's hotspot.
yarn start web
you can use this command to scan the QR code and see the app in you EXPO app at you mobile
You musk permit local network in the application setting in iOS. Otherwise, Metro can not find your app even in the same network.
For iOS on Xcode:
Go to Window > Devices and Simulators, Go to "Installed Apps" section, Click on +, Pick your app , Run your code.
(This issue happened to me when I run the app after I uninstalled it from the device)
For me the solution was to remove the installed app and build run in Xcode again.
Oh, I had the same problem with RN - for me - there was a problem with connecting iphone to macbook server on localhost - and it solved if I just turned off wifi on macbook and then turned it on again. (Yes, it sounds weird - but it's a common problem)
For me, on IOS, Xcode would be stuck in debugging, a breakpoint is active and Metro can't reload because no apps are connected. To solve this:
open Xcode
In the left-hand side panel, click from the top row on Debug navigator (if it's not already focused and in the view like it was for me)
In the bottom pane (which can be minimized fully, in which case you have to hold and drag from the bottom of Xcode to expand it into view) you see a set of debugging buttons, the most left
one is a blue arrow-head-shaped button that continues/unpauses the script, click it.
after unpausing the script my app would connect to Metro.
Easy solution ->
1- Go to Developer options of your phone .
2- Disable adb authorization timeout..
Now reload project and enjoy coding..
My problem was that i added --variant=release
npx react-native run-android --variant=release
So i remove it and worked for me.Like this:
npx react-native run-android

The change on the code not reflected with React Native

I am developing a simple chat program with react native for learning purpose (not use expo). I made changes with the chat message (along with other code change) and was trying to reload the new message with USB debugging on Android device. But the app persistently shows the old message before change. Here is what I did:
Under android subdir, run .\gradlew clean
close android studio and react-native run-android again
Shake the device and choose reload
The #3 causes the error below:
Is there some module like nodemon for nodejs which picks up the code change nice and easily?
I often get this issue too. In this situation, I turn off the debug mode, and run adb reverse tcp:8081 tcp:8081 && react-native run-android again.
Connect your phone to your wifi, and try this,
Trigger the Developer Menu
Go to Dev Settings > Debug server host & port for device
Set it to <your_pc_ip_address_on_local_wifi>:8081. (If you are on a emulator, set it to localhost:8081)
Restart the app

[react-native]Could not connect to development server and unable to symbolicate stack trace(android)

I am new react native.i am developing a app which includes json data fetching by using axios. I made development connection through usb to my pc and app works fine but when i unplug the usb or close the react packager then there is a red screen on start of my app that says could not connect to development server.and then there is a error below in yellow bar that says unable to symbolicate stack trace...how can i get rid of these errors and run my app independently ?
I think according to your question you are closing the development server from commandline or cmd.
Once you disconnect you will have to restart the packager.
TO connect with Api
select the port number from API application url Example: http://localhost:44394
Step 1: Launch the emulator using command in terminal : npx react-native run-android
Step 2: open the app in emulator:
Step 3: enter the command in root terminal: adb reverse tcp:44394 tcp:44394

How to run React Native app on Android Phone

I am building React Native app.
It is working well when I launch the app in terminal on Mac using "react-native run-android".
But when I got the apk file and installed it on another android device manually, it does not work.
It looks like this.
If you are connected via cable, do the following:
1. Goto > Settings > About Device
2. Then Software Info
3. Then > Build Number
4. Now Tap (Click) multiple times on Build Number to Enable Developer Options
5. Here you go not the Developer Options will be visible in your Settings
6. Now Go inside the Developer Options and Enable USB Debugging Mode.
7. Open your terminal
On Windows open Android SDK Manger > Platform Tools
Type:
$ adb devices
This will show you the devices and simulator/virtual-devices that you have on you computer.
8. Forward requests from your device
Type:
$ adb reverse tcp:8081 tcp:8081
9. Run it
Type:
$ npm run android
The app should appear on your device
Looks like the source code in your APK is looking for the package server.
Read this on how to build APKs for react-native: React-Native - Generating Signed APK
If your devices is connected via cable:
If you're on a physical device connected to the same machine, run 'adb reverse tcp:8081 tcp:8081' to forward requests from your device
Otherwise, you can still do this via Wifi by following the last point in the error:
If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and
the port of the local dev server -e.g. 10.0.1.1:8081
Please find the below steps to run react-native code on a physical mobile device:-
Please make sure you are on the same wifi network(Mobile and Laptop).
Run your code and install it on the mobile through the Android Studio.
The app will install and asking you to change your "dev settings".
Shake your phone and go to "dev settings" and type your machine's IP address(192.16.XX.XXX:8081).
Close the app once and open again, in the terminal you will see like this
6. wait for a minute app will install and reflect the changes.
Get a list of all the devices:
adb devices
Then set the which device to run on:
adb -s <device name> reverse tcp:8081 tcp:8081
Then deploy the app:
react-native run-android
If you've upgraded your version of react-native since generating your android project files, you might want to regenerate those now. I think you can use react-native upgrade.
The following are required in order to run a React Native app on Android:
Android Studio
Android SDK
JDK 8 (installation instructions for macOS here and Windows here)
Answer Source: Make An App
We can run the React Native app on Android platform by running the following code in the terminal.
react-native run-android
Before you can run your app on Android device, you need to enable USB Debugging inside the Developer Options.
If you get a “bridge configuration isn’t available” error. Then use below command to solve
adb -s tcp:8081 tcp:8081
Now re-run the app using
react-native run-android
The command for correcting networking on the physical device should instead be:
adb -s reverse tcp:8081 tcp:8081
When USB Debugging is enabled, you can plug in your device and run the code snippet given above.
Configure your app to connect to the local dev server via Wi-Fi
Make sure your laptop and your phone are on the same Wi-Fi network.
Open your React Native app on your device. You can do this the same
way you'd open any other app. You'll see a red screen with an error.
This is OK. The following steps will fix that. Open the Developer
Go to Dev Settings. Go to Debug server host for device. Type in your machine's IP address and the port of the
local dev server (e.g. 10.0.1.1:8081).
On Mac, you can find the IP address in System Preferences / Network. On Windows, open the command
prompt and type ipconfig to find your machine's IP address (more
info).
Go back to the Developer menu and select Reload JS.
The Native Android emulator is slow. We recommend downloading Genymotion for testing your app.
The developer menu can be accessed by pressing command + M.