求助Can't find variable:process,三天都没搞定



  • 嵌入到Android程序中出现错误,我已经三天搞不懂了
    APP错误:
    ReferenceError: Can't find variable: process (http://10.0.3.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:2523)

    AndroidStudio log:
    11-17 22:41:29.673 5617-5617/com.pczhu.www.kfcshow W/unknown:React: Packager connection already open, nooping.
    11-17 22:41:29.735 5617-17301/com.pczhu.www.kfcshow E/unknown:React: Exception in native call from JS
    com.facebook.react.devsupport.JSException: ReferenceError: Can't find variable: process (http://10.0.3.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:2523)
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:739)
    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:148)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: com.facebook.jni.CppException: ReferenceError: Can't find variable: process (http://10.0.3.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:2523)
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
    at android.os.Handler.handleCallback(Handler.java:739) 
    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:148) 
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
    at java.lang.Thread.run(Thread.java:818) 
    11-17 22:41:29.737 5617-17301/com.pczhu.www.kfcshow E/unknown:React: Exception in native call
    java.lang.RuntimeException: Error calling function: RCTDeviceEventEmitter:emit
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:739)
    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:148)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.RuntimeException: Empty Optional cannot be unwrapped
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
    at android.os.Handler.handleCallback(Handler.java:739) 
    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:148) 
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
    at java.lang.Thread.run(Thread.java:818) 
    11-17 22:41:29.738 5617-17301/com.pczhu.www.kfcshow E/unknown:React: Exception in native call
    java.lang.RuntimeException: Error calling function: AppRegistry:runApplication
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:739)
    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:148)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.RuntimeException: Empty Optional cannot be unwrapped
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
    at android.os.Handler.handleCallback(Handler.java:739) 
    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:148) 
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
    at java.lang.Thread.run(Thread.java:818) 
    11-17 22:41:29.741 5617-17301/com.pczhu.www.kfcshow E/unknown:React: Exception in native call
    java.lang.RuntimeException: Error calling function: RCTDeviceEventEmitter:emit
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:739)
    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:148)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.RuntimeException: Empty Optional cannot be unwrapped
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
    at android.os.Handler.handleCallback(Handler.java:739) 
    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:148) 
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
    at java.lang.Thread.run(Thread.java:818) 
    0_1479440436666_QQ20161118-0.jpg



  • 一般是没有安装react,有些文档(包括某些版本的官方文档)可能遗漏了

    npm i react --save
    

    如果安装过程中报错版本不匹配,那么记下其需要的版本

    npm i react@需要的版本 --save
    


  • @sunnylqm 感谢大神,我尝试了你给我的解决方式,发现0.37.0版本一直丢失依赖,没有办法我降级到了0.36.1,依赖无缺失,发现嵌入成功了。感谢大神的帮助。