安装React Navigation和手势处理程序后出现错误

问题描述 投票:1回答:2

我是React-native的新手,并尝试使用Windows版Android Studio中的本地本机构建android应用。安装react-navigation后,请按照react-navigation文档中的所有步骤操作,运行react-native run-android,然后在命令行中收到此错误:

PS C:\Users\comp\Desktop\work\reactnative\dansapp> react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...

FAILURE: Build failed with an exception.

* Where:
Settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\android\settings.gradle' line: 3

* What went wrong:
Could not compile settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\android\settings.gradle'.
> startup failed:
  settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\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:602:13)
    at Object.execFileSync (child_process.js:622:13)
    at runOnAllDevices (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
    at buildAndRun (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
    at isPackagerRunning.then.result (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

PS C:\Users\comp\Desktop\work\reactnative\dansapp>

有人知道这个错误是什么以及如何解决?按照以下步骤安装react-navigation之后,似乎会发生这种情况:https://reactnavigation.org/docs/en/getting-started.html

我遵循了这些步骤,包括更改mainActivity.java文件。我也不知道gradle是什么。

任何帮助将不胜感激!

android react-native android-gradle-plugin android-emulator react-navigation
2个回答
3
投票

已知issue(请参阅:bug with react-native link in android and windows),希望很快会修复。

跳转到/ dansapp / android /中的settings.gradle文件,然后替换...

project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')

...与...

project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')

0
投票

FAILURE:构建因异常而失败。

  • 其中:设置文件'E:\ RN \ sc3 \ android \ settings.gradle'行:4

  • 出了什么问题:无法编译设置文件'E:\ RN \ sc3 \ android \ settings.gradle'。

    启动失败:设置文件'E:\ RN \ sc3 \ android \ settings.gradle':4:意外的字符:'\'@第4行,第133列。s \ react-native-gesture-handler \ android')^可以解决plaese!

© www.soinside.com 2019 - 2024. All rights reserved.