当我尝试运行时,Dimensions.get('window')错误会在Windows中反应本机示例

时间:2017-03-23 09:36:36

标签: reactjs react-native

我想设置Windows反应本机开发环境并学习 来自本机文件夹的示例。

示例apk可以安装在我的Android虚拟机上。

但是当我点击它时,它会弹出红色屏幕,如:

https://i.stack.imgur.com/rPnfo.jpg

和我的打包程序控制台错误:

SyntaxError: Unexpected end of JSON input
    at parse (native)
    at process._tickCallback (internal/process/next_tick.js:109:7)
{ Error: write EPIPE
    at exports._errnoException (util.js:1018:11)
    at Socket._writeGeneric (net.js:715:26)
    at Socket._write (net.js:734:8)
    at doWrite (_stream_writable.js:334:12)
    at writeOrBuffer (_stream_writable.js:320:5)
    at Socket.Writable.write (_stream_writable.js:247:11)
    at Socket.write (net.js:661:40)
    at Socket.Writable.end (_stream_writable.js:480:10)
    at Socket.end (net.js:431:31)

我尝试关注并调试chrome并找到:

return Dimensions.get('window').scale;

得到的错误如下:

Uncaught Error: No dimension set for key window
    at invariant (http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:2504:15)
    at Function.get (http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:17698:7)
    at eval (eval at evaluate (:85:21), <anonymous>:1:12)
    at Function.get (http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:17620:7)
    at Function.roundToNearestPixel (http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:17635:30)
    at http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:17557:32
    at loadModuleImplementation (http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:109:5)
    at guardedLoadModule (http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:70:12)
    at _require (http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:54:60)
    at http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false:18886:18

my react-native版本: “反应”:“15.4.2”, “react-native”:“0.42.3”

我的AVD设置是:

https://i.stack.imgur.com/Vo1Zn.jpg

任何帮助将不胜感激!

谢谢你,最诚挚的问候。

0 个答案:

没有答案