Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native: "could not connect to development server"- android app

I am following guide on starting react.js. http://code.tutsplus.com/tutorials/creating-a-dictionary-app-using-react-native-for-android--cms-24969 I installed node, react, android studio and genymotion emulator. When I get to the part of building app in emulator, I get this error:

error build image

I activated USB debuggin tool. When I try to run adb devices command in command prompt, it gives me nothing.

like image 392
iceQ Avatar asked May 12 '16 07:05

iceQ


2 Answers

I would suggest 2 steps (both were required to solve my issue)

  1. Turn off your local firewall. On osx, go to "Security & Privacy" -> "Firewall" -> Click lock icon -> "Turn off Firewall"

  2. The default port 8081 may be in use (even if the lsof command suggests otherwise). Try another port on start: react-native start --port=8088

    And on your device, shake it to get the dev menu, tap "Dev Settings" -> "Debug server host & port for device" -> enter "XX.XX.XX.XX:8088" (where x's are your local IP)

like image 106
niltoid Avatar answered Oct 23 '22 10:10

niltoid


On Android 9, you will need to add the follwing in application tag of ./android/app/src/debug/AndroidManifest.xml

android:usesCleartextTraffic="true"

https://github.com/facebook/react-native/issues/15388#issuecomment-505187651

like image 37
andho Avatar answered Oct 23 '22 09:10

andho