Could not connect to React Native development server on Android

前端 未结 28 2009
鱼传尺愫
鱼传尺愫 2020-11-30 22:10

When I run react-native run-android, it gives me the following error:

Could not connect to development server

28条回答
  •  再見小時候
    2020-11-30 22:24

    Starting with Android 9.0 (API level 28), cleartext support is disabled by default. we can use android:usesCleartextTraffic="true" this will work but this is not recommended solution. For Permanent and recommended Solution is below:

    Step 1 : create a file in android folder app/src/debug/res/xml/network_security_config.xml

    Step 2 : add this to network_security_config.xml

    
    
      
      
       localhost
       10.0.2.2
       10.0.3.2
      
    
    

    Step 3 : Apply the config to your AndroidManifest.xml

    
    
    

提交回复
热议问题