React与现有应用程序崩溃的本机集成:“找不到变量:__ fbBatchedBridge”

时间:2016-03-01 09:13:34

标签: android facebook react-native

我通过Facebook指南集成了与Android工作室中的现有应用程序本地反应:http://facebook.github.io/react-native/docs/embedded-app-android.html#content

我发现可以通过设置开发菜单来解决“无法找到变量:__ fbBatchedBridge”的错误。就像ReferenceError: Can't find variable: __fbBatchedBridge

一样

但我的问题是我在现有应用程序的活动中显示了React Native页面,它在使用react native视图启动活动时崩溃。

错误日志如下:

java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.facebook.react.bridge.JSExecutionException: ReferenceError: Can't find variable: __fbBatchedBridge (<unknown file>:1)
     at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:160)
     at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:779)
     at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:91)
     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:184)
     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:169)
     at android.os.AsyncTask$2.call(AsyncTask.java:289)
     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
     at java.lang.Thread.run(Thread.java:841)
     Caused by: java.util.concurrent.ExecutionException: com.facebook.react.bridge.JSExecutionException: ReferenceError: Can't find variable: __fbBatchedBridge (<unknown file>:1)
     at com.facebook.react.common.futures.SimpleSettableFuture.get(SimpleSettableFuture.java:68)
     at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:136)
     at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:779) 
     at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:91) 
     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:184) 
     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:169) 
     at android.os.AsyncTask$2.call(AsyncTask.java:289) 

2 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。原来作为react-native v0.21左右,如果您的服务器没有运行,应用程序将崩溃(之前它显示红色错误页面但仍然运行)。只需先启动服务器:

npm start

然后你的应用应该有用。

答案 1 :(得分:0)

停止Google Chrome调试。为我工作