react-native - 构建React Native项目时出现错误

标签 react-native android-gradle-plugin

我收到以下错误

失败:生成失败,发生异常。

* Where:
Settings file 'G:\ReactNative\Contacts\android\settings.gradle' line: 3

    * What went wrong:
    Could not compile settings file 'G:\ReactNative\Contacts\android\settings.gradle'.
    > startup failed:
      settings file 'G:\ReactNative\Contacts\android\settings.gradle': 3: unexpected char: '\' @ line 3, column 133.
         s\react-native-gesture-handler\android')

settings.gradle
rootProject.name = 'Contacts'
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-vector-icons\android')

include ':app'

这个文件实际上有什么问题?

最佳答案

尝试正斜杠/而不是反斜杠\

使用代码

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

include ':app'

而不是
rootProject.name = 'Contacts'
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-vector-icons\android')

include ':app'

希望对你有帮助

关于react-native - 构建React Native项目时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54476682/

相关文章:

javascript - React Native 最小/准系统设置

javascript - 我如何用 Yup 验证两个小时?

javascript - Redux 存储为 immutable.js 映射

android - 如何在 gradle 中生成 Dagger (v1) 对象图 (*.dot)?

javascript - 为什么不允许在 React Native 组件属性赋值中展开运算符是一种性能优化?

react-native - 在 react 原生图表工具包中导入 barChart 中的 Y 标签

java - Java+Kotlin Android 项目中 Kotlin 文件中 Unresolved 引用错误

android - 在 Android 中准备 jar 库时无法获取资源布局文件

android - 如何根据构建变体使用 gradle 编译不同依赖模块的依赖项?

java - IllegalAccessError 运行 android 仪器测试