react-native 打包常见报错和解决方案

1,986 阅读1分钟

Q1.0

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > Could not initialize class com.android.sdklib.repository.AndroidSdkHandler

解决方案

下载jdk1.8.0 设置JAVA_HOME环境变量


Q1.1:

error: Build input file cannot be found: '/${your path}/node_modules/react-native/third-party/double-conversion-1.1.5/src/double-conversion.cc'

解决方案

运行以下命令,注意 glog 必须是当前版本,否则找不到

$ cd node_modules/react-native/scripts && ./ios-install-third-party.sh && cd ../../../ $ cd node_modules/react-native/third-party/glog-0.3.4/ && ../../scripts/ios-configure-glog.sh && cd ../../../../

详见github issue

————

Q1.2

Could not find iPhone 6 simulator

解决方案

找到并修改项目下 /node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js 文件

    // 找到这行
    if (version.indexOf('iOS') !== 0) {
      continue;
    }

    // 改为这行
    if (version.indexOf('iOS') !== 0 && !version.includes('iOS')) {
      continue;
    }

————

Q1.3:

error: Can't find 'node' binary to build React Native bundle

解决方案

在 xcode 里 'Build Phases' - 'Bundle React Native code and images', 把当前环境变 量添加进去 export NODE_BINARY=/Users/gridsum/.nvm/versions/node/v8.9.0/bin/node

————

Q1.4:

Could not list contents of '/${yourpath}/node_modules/react-native/scripts/third-party/glog-0.3.4/test-driver'.

Couldn't follow symbolic link.

解决方案

运行

unlink ./node_modules/react-native/scripts/third-party/glog-0.3.4/test-driver