构建React Native项目时出现错误

时间:2019-02-01 09:37:54

标签: react-native android-gradle

我遇到以下错误

失败:构建失败,并出现异常。

* 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 个答案:

答案 0 :(得分: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'

希望这会有所帮助