在settings.graddle中反应本机意外的字符:'\'

时间:2019-02-15 11:51:42

标签: android reactjs react-native webview

我正在尝试在干净的React Native安装中设置Webview进行测试。这是我采取的步骤:

  1. 本机初始化Webview
  2. cd webview
  3. yan add react-native-webview
  4. 本机链接react-native-webview
  5. react-native run-android

但是,它崩溃并显示以下内容:

$ 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\Lucas10\ReactNative\webview\android\settings.gradle' line: 3

* What went wrong:
Could not compile settings file 'C:\Users\Lucas10\ReactNative\webview\android\settings.gradle'.
> startup failed:
  settings file 'C:\Users\Lucas10\ReactNative\webview\android\settings.gradle':3: unexpected char: '\' @ line 3, column 117.
     e_modules\react-native-webview\android')

如果我编辑android / settings.graddle并替换:

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

使用

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

它可以正常编译。

这似乎是react-native和Windows之间的兼容性烦恼...?

如何解决此问题,这样就不必在每次添加软件包时都进行手动调整?

0 个答案:

没有答案