React Native版本不匹配-JavaScript 0.52.0和Native 0.56.0

时间:2018-07-30 09:56:47

标签: react-native

运行以下图像的android应用时出现错误:

enter image description here

对于package.json:

{
  "name": "Training",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0"
  },
  "devDependencies": {
    "babel-jest": "23.4.2",
    "babel-preset-react-native": "5.0.2",
    "jest": "23.4.2",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

android/app/gradle.properties

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    compile "com.facebook.react:react-native:+" // From node_modules
}

如何解决该问题?

2 个答案:

答案 0 :(得分:0)

  1. 关闭所有终端(从而停止所有正在运行的捆绑器)
  2. 可选:清除缓存
  3. 可选:确保您的构建使用正确的版本,您可以运行:./gradlew androidDependencies并检查输出结果,以反映您的构建实际使用的本机版本(0.56或0.52)
  4. 从设备上卸载应用,然后重新安装!

答案 1 :(得分:0)

我通过以下方法解决了这个问题:

  1. 重新启动PC(Linux Mint 17.3)
  2. 擦除模拟器数据
  3. 然后运行最终命令:react-native run-android