我在 Android 中遇到了 React-Native 问题 (无法获取 BatchedBridge,请确保您的捆绑包正确打包) [![在此处输入图像描述][1]][1]
我尝试了一切:将 npm、react-native、react 和 package.json 中的所有依赖项更新到最新版本, 我删除了node_modules并再次重新安装,清除缓存... atc
错误日志
04-25 03:35:49.874 11688-11814/com.test.store E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: com.test.store, PID: 11688
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Could not get BatchedBridge, make sure your bundle is packaged correctly
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:24)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:161)
at com.facebook.react.cxxbridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:465)
at com.facebook.react.cxxbridge.CatalystInstanceImpl.access$400(CatalystInstanceImpl.java:51)
at com.facebook.react.cxxbridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:481)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:33)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
at java.lang.Thread.run(Thread.java:761)
Caused by: com.facebook.react.devsupport.JSException: Could not get BatchedBridge, make sure your bundle is packaged correctly
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
at java.lang.Thread.run(Thread.java:761)
Caused by: com.facebook.jni.CppException: Could not get BatchedBridge, make sure your bundle is packaged correctly
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
at java.lang.Thread.run(Thread.java:761)
我也遇到了同样的问题,然后我遵循了这个答案(错误“无法获取BatchedBridge,请确保你的捆绑包在应用程序启动时正确打包”),然后它就像一个魅力......!
干杯:)
目前
react-native-router-flux
包存在一个错误。它包括一个react-native 的重复实例。您需要做的就是npm install
您的包,然后删除重复的react-native条目。
rm -r ./node_modules/react-native-router-flux/node_modules/react-native
对我来说,问题是“adb”未被识别。当我尝试运行我的项目时,没有明显迹象表明“adb”有问题,但是当我尝试运行空白项目时,它显示命令“adb”未被识别。
要解决此问题,请将 C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools 添加到环境变量
对我有用的是以下内容。
运行
npm start
,这给了我一个错误ENOSPC
。
我用这个答案修复了这个错误https://stackoverflow.com/a/32600959/706798。
然后我再次运行
react-native run-android
,一切正常!
清除 Windows 温度数据。 (Win+R) 输入 temp 和 %temp% 文件。之后 npm start 或 npx react-native start (用于 Metro start)和 npx react-native run-android (用于在设备中运行应用程序)。这对我有用。 快乐编码。 :)