安装反应导航和手势处理程序后出现错误gradlew.bat installDebug

时间:2019-02-03 16:02:46

标签: react-native react-navigation gesture

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

但是当我安装react导航和手势处理程序后,我得到的错误是命令失败:运行命令react-native run-android后gradlew.bat installDebug 我不知道这是怎么回事...我的旧React Native项目运行得很好。

我记得昨天我在一个旧项目中运行了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)

2 个答案:

答案 0 :(得分:16)

哦,是的,我认为这是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 / android'

然后react-native运行Android

答案 1 :(得分:0)

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