构建React Native项目时出现错误

6
我遇到了以下错误:
构建失败:发生异常。
* 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'

这个文件究竟有什么问题?
1个回答

11

请使用正斜杠 / 替代反斜杠 \

使用代码

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'

希望这能有所帮助


嘿,你能帮我解决这个错误吗?构建失败并出现异常:“无法编译设置文件'project/android/settings.gradle'”。 - Anuj Sharma
rootProject.name = 'PortalAPP' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' 这是我的代码 - Anuj Sharma

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接