React-native: Can't find variable: __fbBatchedBridge (line 1 in the generated bundle)

Created on 20 Dec 2015  路  29Comments  路  Source: facebook/react-native

new project on react-native 0.17.0 Android

does anyone experience this too?

answers as below:
adb reverse tcp:8081 tcp:8081

Locked

Most helpful comment

@qbig @steve-ng @trungdq88 I found what's the reason of this issue, first make sure you have watchman installed if you're on windows or linux; https://facebook.github.io/watchman/docs/install.html

Then you make sure to run react-native start before running react-native run-android so that the server, and the packager is running... you'll most likely anyway hit the error.

Shake your device or hit the menu and go to Dev Settings, Debug Server host and port, seek for the host and port of your computer, and put them there... eg. 192.168.1.4:8081 in my case, then shake again and click reload JS, all it's set up :)

All 29 comments

Hey steve-ng, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or not sure whether some behavior is expected or a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

@steve-ng There is a chance that your packager is not running. This happens when you tried to pass an empty bundle file to jsc to execute.

thanks @qbig is there any possible place that I can check this? I didn't fiddle with my packager

I got this error too

I'm getting this error as well, however if I switch to production then it doesn't happen.

@steve-ng not sure but if you 'npm start' at your project dir did the packager start normally? @onzag if you switch to production, you would be using a pre-bundle file. So it wouldn't happen.

@qbig I understand that, what I'm supposing is that the server is not actually running; but my question is, as I run react-native run-android I don't really seem to get any server running, I'm trying to find out where it is, but all the good guides I find are for xcode. I'm a bit lost here.

Having a same issue here. Can't run the default project on Android (iOS works).

@qbig @steve-ng @trungdq88 I found what's the reason of this issue, first make sure you have watchman installed if you're on windows or linux; https://facebook.github.io/watchman/docs/install.html

Then you make sure to run react-native start before running react-native run-android so that the server, and the packager is running... you'll most likely anyway hit the error.

Shake your device or hit the menu and go to Dev Settings, Debug Server host and port, seek for the host and port of your computer, and put them there... eg. 192.168.1.4:8081 in my case, then shake again and click reload JS, all it's set up :)

Also make sure you have the gradle daemon running just that it doesn't take ages. https://docs.gradle.org/2.9/userguide/gradle_daemon.html happy coding :)

@onzag thank you, it works now. Btw, my server is automatically start when I run react-native android, so I think might be a gradle daemon problem. (Or is it just works because I just have restarted my device?)

@trungdq88 well to be fair I'm not sure, I've never used gradle before, also, I'm on linux mint now, it might be a platform differences problem, if you're using mac that's what it supposed to happen.

I also noticed that the device has to be connected to the same network of the computer, I'm trying to find a workaround for offline usage, because making sure that the device is connected wirelessly in the same LAN of the computer could be annoying in some circumstances.

how to solve this?

Same here.

I tried to run react-native start and I got:

Looking for JS files in
   /home/andrey/Projects/React/NativeTest 

[11:31:16] <START> Building Dependency Graph
[11:31:16] <START> Crawling File System
[11:31:16] <START> Loading bundles layout
[11:31:16] <END>   Loading bundles layout (0ms)

React packager ready.

Next I tried to issue in another terminal the command react-native run-android to run in my Nexus 5, connected to my laptop. The packager terminal added the following:

[11:31:43] <END>   Crawling File System (26401ms)
[11:31:43] <START> Building in-memory fs for JavaScript
[11:31:47] <END>   Building in-memory fs for JavaScript (4036ms)
[11:31:47] <START> Building in-memory fs for Assets
[11:31:51] <END>   Building in-memory fs for Assets (3884ms)
[11:31:51] <START> Building Haste Map
[11:31:53] <START> Building (deprecated) Asset Map
[11:31:53] <END>   Building (deprecated) Asset Map (777ms)
[11:31:54] <END>   Building Haste Map (3028ms)
[11:31:54] <END>   Building Dependency Graph (37950ms)

The app starts in my Nexus, but still the error occurs.
Any tips?

I got the same error when i try to run react-native/Examples/UIExplorer release apk.I slove it after I change the BundleAssetName and JSMainModuleName in react-native\Examples\UIExplorer\android\app\src\main\java\UIExplorerActivity.java.
Maybe you can try correcting your React-Native Actitivy.

Make sure that you also run adb reverse tcp:8081 tcp:8081 when testing on device.

@satya164 based on the number of ppl got stuck on this, maybe #4739 ? Should be a useful but minor fix. Or would you suggest other approach like fixing the doc?

@qbig A PR to improve the error message is much appreciated.

Just to make it clear, this error shows after updating react-native dependencies to 0.17.0
The very same code "works" with react-native 0.16.0 (packager running, reverse proxy set)

@andreyluiz Currently you have to shake your device and pick in Dev settings the ip and port of your computer so that the device can access the server.

@dkokic in 0.17.0 you don't need to set the reverse proxy... you just have to set the IP and port of your computer, that's for remote usage, so it makes sense to use it that way. However I may be wrong, I only started using this library 1 week ago.

Related to #4739, PR welcome to improve the message!

Thanks @satya164, adb reverse tcp:8081 tcp:8081 this fixed my issue.

It worked. @satya164 :+1:

adb reverse tcp:8081 tcp:8081
this only works for android 5.0+ (API 21)

Same here, I tried to run it on genymotion emulator. I had to run adb reverse tcp:8081 tcp:8081, then react-native start then react-native run-android to run an android app on Ubuntu 14.04. I am using react-native 0.17.0 as a dependency.

My problem solved!
I was getting this error when i try to
react-native run-android on stock android avm
screenshot_2016-02-15-13-32-08-

What I do?
After Run react-native run-android and get "_fbBatchedBridge" error,
i run react-native start
react-packager
Then clicked "Reaload JS" button on AVM,
Then waited for some(about 1.5 min) process in packager and i get this:
react-packager2

Then my app ready:
react-avm-running

If you still cant reload your JS. In windows(AVM);

Press F2 -> Dev Settings -> Debug server host & port for device -> Write "localhost:8081"

For your Android Device(Physical) on same Wifi
Press F2 -> Dev Settings -> Debug server host & port for device -> Write "(Your pc ip address):8081"

@stavash Thanks. It works. I think this answer should go to tutorial.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oney picture oney  路  3Comments

josev55 picture josev55  路  3Comments

aniss picture aniss  路  3Comments

WG-Com picture WG-Com  路  3Comments

lazywei picture lazywei  路  3Comments