【问题标题】:getting error gradlew.bat installDebug after installing react navigation and gesture handler安装反应导航和手势处理程序后出现错误 gradlew.bat installDebug
【发布时间】:2019-02-03 16:02:46
【问题描述】:

我使用命令 react-native init appName 创建了新的 react native 应用程序。 应用程序创建成功后,使用命令 react-native run-android 将其安装到我的设备中,它安装成功,并且工作正常...没问题

但是一旦我安装了反应导航和手势处理程序,我在运行命令 react-native run-android 后收到 Command failed: gradlew.bat installDebug 错误 我不知道出了什么问题……我以前的 react 原生项目运行良好。

我记得昨天我在我的一个旧项目中运行了命令 gradlew clean。这对我的新项目有影响吗?

如果有人帮忙,我会非常感激

这是完全错误

  FAILURE: Build failed with an exception.

  * Where:
  Settings file 'D:\React Native Apps\Practice\newapp\android\settings.gradle' line: 3

  * What went wrong:
  Could not compile settings file 'D:\React Native Apps\Practice\newapp\android\settings.gradle'.
  > startup failed:
  settings file 'D:\React Native Apps\Practice\newapp\android\settings.gradle': 3: unexpected char: '\' @ line 3, column 133.
     s\react-native-gesture-handler\android')
                                   ^

  1 error


  * 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 1s
  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/getting-started.html

  Command failed: gradlew.bat installDebug

  Error: Command failed: gradlew.bat installDebug
     at checkExecSyncError (child_process.js:616:11)
     at Object.execFileSync (child_process.js:634:13)
     at runOnAllDevices (D:\React Native Apps\Practice\newapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
     at buildAndRun (D:\React Native Apps\Practice\newapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
     at isPackagerRunning.then.result (D:\React Native Apps\Practice\newapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
     at process._tickCallback (internal/process/next_tick.js:68:7)

【问题讨论】:

  • 你链接react-native-gesture-handler了吗?
  • 是的,我做了链接...
  • 你修改MainActivity.java了吗?
  • 是的,我按照反应导航文档中的说明做了...添加了一些文件
  • 发布了完整的错误...它在 settings.gradle 文件中说一些问题,但它与我的旧项目相同

标签: react-native react-navigation gesture


【解决方案1】:

哦,是的,我认为这是 RN 0.58 链接命令的错误

使用文本编辑器从 => 'D:\React Native Apps\Practice\newapp\android\settings.gradle' 打开 settings.gradle

将所有 '\' 替换为 '/' ,在我的情况下,我必须将 '..\node_modules\react-native-gesture-handler\android' 替换为 '../node_modules/react-native-gesture-handler /机器人'

然后 react-native run-android

【讨论】:

  • 非常感谢我们都对来自 RN 的这些错误感到厌烦 :(
  • 顺便说一句,这个bug不是由react native引起的,而是由react native cli引起的
【解决方案2】:

确保你已经安装了 python 2 和最新版本的 jdk 并确保你已经设置了 ANDROID_HOME 你应该遵循这个结构:https://facebook.github.io/react-native/docs/getting-started.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-01
    • 2019-06-22
    • 2021-11-08
    • 1970-01-01
    • 2021-05-27
    • 1970-01-01
    • 2014-06-19
    • 2019-07-13
    相关资源
    最近更新 更多