0

I tried to build a fresh React Native project on Android 4.4 (Kit Kat) device.But it failed to load the bundle the metro server starts but bundling does not start and after few suggests from other post i tried to set the IP and host manually using the dev menu but still same error.Any suggestions on how to resolve the issue.

Device Name: Zebra TC/70 device

React Native Version : 0.55.3

Error Screen

ip & host set manually

Yes the Metro Bundler is started

[SOLVED] : The only solution that solved me is i upgraded the device to Lollipop since adb could not be done in Android version< 5.0 and no other solution like setting manually the ip and host through dev settings worked

anbu selvan
  • 725
  • 3
  • 13
  • 41
  • Is the bundler terminal running and compiling correctly? – Nino9612 Oct 15 '18 at 08:55
  • Yes the metro bundler is started – anbu selvan Oct 15 '18 at 09:17
  • Have you tried to press enter when after you clicked inside the terminal window? Because as far as is can see from the screenshot you posted the bundler hasent event started doing his work – Nino9612 Oct 15 '18 at 09:24
  • no no error shows up in metro bundler terminal but i get the following error while running react-native run-android :- `Running C:\Users\selvaanb\AppData\Local\Android\sdk/platform-tools/adb -s 17055522501922 reverse tcp:8081 tcp:8081 error: closed Could not run adb reverse: Command failed: C:\Users\selvaanb\AppData\Local\Android\sdk/platform-tools/adb -s 17055522501922 reverse tcp:8081 tcp:8081` – anbu selvan Oct 15 '18 at 09:26
  • yes usually the dependency loads with a progress bar when i built in higher version android 5.0+ but when i run the same app in version 4 not response in metro bundler. – anbu selvan Oct 15 '18 at 09:28
  • looks like the error you get "Could not run adb reverse" is because you try to compile for android 4.4 check this post: https://stackoverflow.com/questions/45229579/could-not-run-adb-reverse-react-native it explains a little bit make sure to go through the possible soultions and see if that works for you. – Nino9612 Oct 15 '18 at 09:35
  • I personally havent developed a app targeting 4.4 but as far as is know the metro bundler shows a little bit more then only the info that hes done loading dependencies. Like for example something like this: https://i.stack.imgur.com/kPVFi.png – Nino9612 Oct 15 '18 at 09:36
  • thanks for your suggestions @Nino9612 yes i tried manually entering the ip and host but still the same problem.And regarding the metro bundler when i run in an emulator with 4.4 version then the metro bundler loads the dependency with progress bar and the app runs successfully but when i build the same app in real android device 4.4 then bundler doesn't not load beyond that point. – anbu selvan Oct 15 '18 at 09:44
  • okay thats weird. The bundler should be platform independent so its should not matter if you are running the app on a real device or a emulator as far as bundling and serving the code goes. Hmm... the devices are on the same network? – Nino9612 Oct 15 '18 at 10:14
  • @Nino9612 yes it is the same network – anbu selvan Oct 15 '18 at 10:27
  • Then im sorry i dont know more normaly it should work. Maybe its something special – Nino9612 Oct 15 '18 at 10:30
  • No problem thanks for your helps :-) – anbu selvan Oct 15 '18 at 10:45

1 Answers1

0

I found this solution on a Github issue and it worked for me:

(Make sure rn server is running npm start, delete app-debug.apk from android/app/build/outputs/apk , uninstall from android if previously installed and run following commands from root folder)

  1. create dir mkdir android/app/src/main/assets

  2. create file index.android.js which is a clone of index.js cp index.js index.android.js

  3. react-native link

  4. curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

  5. react-native run-android

Paul Onteri
  • 577
  • 6
  • 11