ReferenceError: Can't find variable: __fbBatchedBridge

后端 未结 8 2014
花落未央
花落未央 2021-02-05 00:55

Using just the default code from react-native init AwesomeProject, when I run the app I get the \'ReferenceError: Can\'t find variable: __fbBatchedBridge (line 1 in

相关标签:
8条回答
  • 2021-02-05 01:11

    This worked for me according to documentation

    http://facebook.github.io/react-native/docs/running-on-device-android.html#content

    Using adb reverse Note that this option is available on devices running android 5.0+ (API 21).

    Have your device connected via USB with debugging enabled (see paragraph above on how to enable USB debugging on your device).

    1. Run adb reverse tcp:8081 tcp:8081

    You can use Reload JS and other development options with no extra configuration

    1. Then Run react-native run-android which will automatically start dev server on 8081 port on your dev machine if not already running.
    0 讨论(0)
  • 2021-02-05 01:12

    Thank you rmevans9 and Anonsage for your answers!

    I am using HTC One on Ubuntu and there is no menu option, anyway this is the summary of the answers that worked for me:

    1. Create the project $ react-native init MyProject $ cd MyProject/

    2. In first console tab run and leave it running as you develop (react-native start alternative): $ npm start

    3. In second console tab compile and install the project (connect the device to the USB if you want): $ react-native run-android

    4. Fix ReferenceError: Can't find variable: __fbBatchedBridge:

      • Find you local ip address by executing ifconfig on Linux/Mac, for example: inet addr:192.168.0.3
      • Shake the device to see menu options while app is running (if you don't have "Menu" button)
      • Go to Dev Settings -> Debug server host & port for device in Debugging section and copy your local ip address with the specific port: 192.168.0.3:8081 (the port can be viewed when running npm start from the first tab) then go/press Back
      • Shake the device to see menu options again and press Enable Live Reload (to see changes live when editing)
      • Shake the device to see menu options again and press Reload JS
    0 讨论(0)
  • 2021-02-05 01:14

    I encountered this when I had specified different react native versions in my packages.json and my build.gradle file. Making sure they matched, running npm update, and rebuilding from android studio fixed the issue for me.

    0 讨论(0)
  • 2021-02-05 01:19

    i solved it using this command

    adb reverse tcp:8081 tcp:8081
    
    0 讨论(0)
  • 2021-02-05 01:19

    I had the same problem.

    As I followed all the steps mentioned in other answers, I could not resolve the issue.

    In my case the firewall was blocking the packets coming from android.

    0 讨论(0)
  • 2021-02-05 01:25

    I had the same issue while using Visual Studio Android Emulator. When the red screen shows up type in the command line

    adb shell input keyevent 82
    

    This will trigger the shake event and launch the dev menu

    Then hit Dev Settings > Debug server host & port for device and enter <your ip adress>:8081. If for some reason you cannot type in the field you can trigger the text action in the command line by using

    adb shell input text <your ip adress>:8081
    
    0 讨论(0)
提交回复
热议问题