无法在Android上运行React-Native新项目

时间:2019-09-27 08:16:54

标签: android react-native gradle

当我尝试使用react-native run-android运行项目时,它向我显示此错误:error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment.

此外,当我从Android Studio运行时,它显示以下错误:ERROR: Android dependency 'org.webkit:android-JSC:r245459' is set to compileOnly/provided which is not supported

这是我的package.json文件:

    {
  "name": "churchmap",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.9.0",
    "react-native": "0.61.1"
  },
  "devDependencies": {
    "@babel/core": "^7.5.0",
    "@babel/runtime": "^7.5.0",
    "@react-native-community/eslint-config": "^0.0.3",
    "babel-jest": "^24.1.0",
    "jest": "^24.1.0",
    "metro-react-native-babel-preset": "^0.51.1",
    "react-test-renderer": "16.8.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

我不明白为什么不起作用

1 个答案:

答案 0 :(得分:2)

我用maven {url'https://jitpack.io'}替换了maven {url'https://www.jitpack.io'},然后下载了jetifier npm install --save-dev jetifier并运行了npx jetifier。那解决了我的问题:)