美文网首页
React-native运行坑

React-native运行坑

作者: 江南_烟雨 | 来源:发表于2018-04-23 15:18 被阅读0次
    1. Metro Bundler can't listen on port 8081

    解决办法:开启了多个服务,全部关掉,在项目路径下,重新start

    2.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/getting-started.html

    解决办法:
    1.android,项目运行环境改变,符合android原生开发时的情况。

    • 项目build.gradle。tools.build > 3.0,repositories需要添加maven { url "https://jitpack.io" }
      google()

    • gradle-wrapper.properties。版本使用本地默认使用

    • 删除node_modules。改变package.json里面"babel-preset-react-native": "5.0.0" to "babel-preset-react-native": "2.0.1"。Terminal重新npm install,关掉服务,重新start。

    • 以上还是报错,一定要看Terminal。比如:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.打开studio,编译下环境,再 react-native run-anroid

    一切ok

    相关文章

      网友评论

          本文标题:React-native运行坑

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