RN

React Native问题汇总

2016-12-14  本文已影响2496人  ChenME

初学 react-native,遇到N多的坑,在这里记录一下,便于以后查找:


  1. 环境配置好,一切OK,运行时出现以下问题:
ChenMengEndeMacBook-Pro:ReactNativeLearningAndroid CME$ react-native run-android
Starting JS server...
Running /Users/CME/Documents/EclipseExplorer/android-sdk-macosx/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && ./gradlew installDebug...
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

从字面上看就是环境连接不到我的模拟器或者是手机,造成这种情况有很多原因。在github上找到解决方法:(从我的解决方式来看,是我的权限不够造成的)

    //1.在app的根目录下运行
    chmod 755 android/gradlew
    //2.然后再运行就正常了
    react-native run-android
  1. 利用命令行运行ReactNative时出现以下提示
    Command `start` unrecognized. Did you mean to run this inside a react-native project?

博客找到以下解决办法:

    npm install react --save
    npm install --save react-native@最新版本号

注:个人分析是因为版本的问题,所以进行更新(没有做过尝试,下次试一下)

    npm update -g react-native-cli
  1. 利用Android的adb工具免数据线调试

在Android -> SDK -> platform-tools文件夹下运行

adb reverse tcp:8081 tcp:8081
上一篇 下一篇

猜你喜欢

热点阅读