美文网首页
react-native本地服务器未连接的问题

react-native本地服务器未连接的问题

作者: iTsung | 来源:发表于2017-01-19 16:24 被阅读0次

    最近在折腾react-native,首先当然是安装环境,在输入run-native run-android命令后出现大量错误,最后听取季哥的建议,通过利用AndroidStudio的方式来运行,在导入后运行,一开始是出现白色界面,什么都不显示。

    后来经过对SDK版本的修改,相关gradle版本的更新,出现如图,显示本地服务器没有连接,打开

    打开localhost:8081,,果然本地服务器没有连接,如果连接了(会显示一大段js代码)

    然后通过

    npm start 打开本地服务器

    然后通过Ctrl+ M,Reload,就可以看到运行的结果了(另外要注意index.android.js文件中的类名,文件名要一致,之前就因为这个没注意,运行错误)

    最终运行成功,如图:

    PS C:\Users\wong\MyProject> react-native run-android

    JS server already running.

    Running C:\Users\wong\AppData\Local\Android\sdk;/platform-tools/adb -s emul

    ator-5554 reverse tcp:8081 tcp:8081

    Could not run adb reverse: spawnSync C:\Users\wong\AppData\Local\Android\sd

    k;/platform-tools/adb ENOENT

    Building and installing the app on the device (cd android && gradlew.bat install

    Debug)...

    FAILURE: Build failed with an exception.

    * What went wrong:

    A problem occurred configuring project ':app'.

    > The SDK directory 'C:\Users\wong\AppData\Local\Android\sdk;' does not exi

    st.

    * Try:

    Run with --stacktrace option to get the stack trace. Run with --info or --debug

    option to get more log output.

    BUILD FAILED

    Total time: 4.875 secs,

    Could not install the app on the device, read the error above for details.

    Make sure you have an Android emulator running or a device connected and have

    set up your Android development environment:

    https://facebook.github.io/react-native/docs/android-setup.html

    相关文章

      网友评论

          本文标题:react-native本地服务器未连接的问题

          本文链接:https://www.haomeiwen.com/subject/lqyibttx.html