3

I would like to develop an app in Create React Native App in the environment where connecting from the Android device to the development server is not possible.

I have installed Android development tools on my laptop and the device is connected to it via USB. When I run npm run android everything starts correctly as it should, Expo is opened in the device but then it ends with an errors:

Could not load exp://192.168.128.150:19000. Can't connect to internet. Please try again

Does this mean that I cannot use Create React Native app without network between the mobile device and the working computer ?

ps-aux
  • 11,627
  • 25
  • 81
  • 128

2 Answers2

1

It might not be the best solution, but it worked for me and i hope it'll be enough to help you out!

I was having the same problem and did the following:

  1. Connected the device to the PC through the USB Port
  2. Verified if it was authorized using adb devices
  3. Disconnected the PC/Laptop from the internet
  4. Ran npm run android with the device connected
  5. Waited for the Javascript Bundle to be built
  6. Reconnected the PC to the network after the application was running on the device

After that i could normally develop through the USB! Hope i've been of help!

0

I've struggled with that for last couple of days with my development environment on the virtualized Ubuntu 18.04. I have 2 interfaces on the guest machine (host-only as ens33, and bridge as ens39).

First of all I've installed react-native-cli to work on.

The steps I do to work only with USB cable (e.g. in VPN network with no chance to connect the device):

  1. Bring all all interfaces listed in etc/etc/interfaces down. , e.g. sudo ifdown ens33. In my case only host-only is listed there so I can still work with the bridge interface.
  2. Connect the device through USB port.
  3. Run adb usb and then adb devices.
  4. Just in case run adb reverse tcp:8081 tcp:8081.
  5. Run react-native start --reset-cache in one terminal. If you have an error with ENPOSC while starting Metro Bundler on 8081 port then follow the instructions here: Node.JS Error: ENOSPC.
  6. In the second terminal run react-native run-android. If all things went good you should see "exp://127.0.0.1:19000" on the screen just under QR code and running app on the device.
Maciek Leks
  • 1,288
  • 11
  • 21