1

I compiled react-native on Android v4.4.2 but the problems arised:

enter image description here

I tried to follow this solution, but I did not how to run on Command Prompt Windows 10:

$> cd myproject  
$> react-native start > /dev/null 2>&1 &  
$> curl "http://localhost:8081/index.android.bundle?platform=android" -o
> "android/app/src/main/assets/index.android.bundle

$> (cd android/ && ./gradlew assembleDebug)

I tried to compile the same way on Android V6.0. Then there was no problem at all.

How to make android V4.4.2 also can be use like Android v6.0 for my first react-native project development?

Community
  • 1
  • 1
Nere
  • 4,097
  • 5
  • 31
  • 71
  • I tried same on Windows 10, but android emulator is still showing the error, tried many other things, too, no fix – pixel Nov 28 '17 at 20:17

2 Answers2

4

That error means your React Native app can't fetch your JS files from your localhost. You'd usually just run react-native start to serve the JS files from your packager, but Android 4.4.x cannot connect to your localhost with the default adb reverse method.

The way I run on Android 4.4.x is to manually set the device to connect to my machine via Wi-Fi (Official guide here!).

  1. Access the React Native dev menu by shaking your device or pressing the hardware menu button (can be done with Ctrl+M or Cmd+M in a simulator, IIRC)
  2. Go to Dev Settings
  3. Under the Debugging section, tap "Debug server host & port for device"
  4. Enter your machine's IP address, as well as the port through which the React Native packager is serving, e.g. "10.0.0.25:8081" (make sure your device and your machine are on the same network!)
  5. Reload through the dev menu again (or by pressing Ctrl+R or Cmd+R in a simulator, I think)
Ian Emnace
  • 1,088
  • 11
  • 14
0

Try running this command

adb reverse tcp:8081 tcp:8081
Andreyco
  • 22,476
  • 5
  • 61
  • 65
  • What actually was happened? – Nere Jan 05 '17 at 13:31
  • `adb reverse` only works for Android 5.0 and above; OP asks for Android 4.4.2. EDIT: Also just as an FYI, the way I understand it, `adb reverse` binds your Android device's ports to your own machine's ports, so accessing port 8081 would link your device to your package manager running on port 8081 on your localhost. – Ian Emnace Jan 05 '17 at 14:52