应用程序上的react-native运行android时生成错误而没有更改

时间:2019-11-06 21:21:53

标签: android react-native

我有一个React Native 0.61应用程序,该应用程序运行良好,但并非没有任何变化,我知道。这是react-native run-android时的错误:

FAILURE: Build failed with an exception.

* Where:
Script 'C:\D\code\js\emps_fe7\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 182

* What went wrong:
A problem occurred evaluating script.
> Text must not be null or empty

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s

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. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* Where:
Script 'C:\D\code\js\emps_fe7\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 182

* What went wrong:
A problem occurred evaluating script.
> Text must not be null or empty

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s

    at checkExecSyncError (child_process.js:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (C:\d\code\js\emps_fe7\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at buildAndRun (C:\d\code\js\emps_fe7\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at then.result (C:\d\code\js\emps_fe7\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

我所做的是从头开始重建项目,并逐个添加每个模块。但是错误是完全相同的。该项目过去很好,并且已经从中生成了apk。我对这里可能发生的问题感到迷茫。这是package.json的依赖项:

"dependencies": {
    "@react-native-community/async-storage": "^1.6.2",
    "moment": "^2.24.0",
    "react": "16.9.0",
    "react-native": "0.61.4",
    "react-native-cli": "^2.0.1",
    "react-native-confirmation-code-field": "^4.1.0",
    "react-native-device-info": "^5.2.1",
    "react-native-elements": "^1.2.7",
    "react-native-gesture-handler": "^1.5.0",
    "react-native-gifted-chat": "^0.11.3",
    "react-native-keychain": "^4.0.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-modal": "^11.5.1",
    "react-native-modal-datetime-picker": "^7.6.0",
    "react-native-reanimated": "^1.4.0",
    "react-native-segmented-control-tab": "^3.4.1",
    "react-native-vector-icons": "^6.6.0",
    "react-native-video": "^5.0.2",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^1.10.3",
    "react-navigation-tabs": "^2.5.6",
    "socket.io-client": "2.1.1"
  },

1 个答案:

答案 0 :(得分:0)

您好,请添加最新的@ react-native-community / cli-platform-android:“ ^ 3.0.3”并删除以前的节点模块,然后在我的情况下运行npm install来解决此问题。 请检查以下图片。因为新的react native需要本地安装的react native cli,而不是全局的react native cli。

Please check image