27

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.

hakkikonu
  • 5,515
  • 6
  • 59
  • 105

18 Answers18

28

⚠️ 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

Azylaans
  • 675
  • 6
  • 17
13

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.

Vaibhav Saini
  • 131
  • 1
  • 3
  • 1
    `adb reverse tcp:8081 tcp:8081` did the trick for me. useful since sometimes my physical android device seems to lose connection. this is instant fix, as opposed to cleaning gradle and rebuilding android – Fre Timmerman Oct 26 '21 at 12:55
12

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.

8

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:

Bundle Location Change Dialog

and they started to communicate with each other.

tidalwave
  • 116
  • 1
  • 3
7

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!

jsog
  • 776
  • 7
  • 10
3

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

Burak
  • 594
  • 1
  • 10
  • 18
2

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

Iroshana
  • 41
  • 5
1

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.

atoth
  • 766
  • 1
  • 7
  • 19
1

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
Asad Shah
  • 11
  • 1
0
yarn start web

you can use this command to scan the QR code and see the app in you EXPO app at you mobile

spoorthi vaidya
  • 349
  • 3
  • 7
0

My problem is that the device is not connected to the internet. Throws the error. Try connecting stable internet connection.

Rushabh Shah
  • 620
  • 4
  • 21
0

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).

gignu
  • 878
  • 1
  • 9
  • 17
0

You musk permit local network in the application setting in iOS. Otherwise, Metro can not find your app even in the same network.

xiaolun
  • 23
  • 8
0

When I remove network_security_config.xml and remove the following:

  `android:networkSecurityConfig="@xml/network_security_config"`

It works

Salahuddin Ahmed
  • 3,154
  • 3
  • 10
  • 33
Yusuf T.
  • 33
  • 3
0

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)

0

I tried everything and after running

adb reverse tcp:8081 tcp:8081
yarn android 

it worked.

Jakov Gl.
  • 171
  • 2
  • 9
0

For me the solution was to remove the installed app and build run in Xcode again.

-1

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
masoud sharifi
  • 93
  • 5
  • 16