1

I'm trying to set up webview in a clean React Native installation to test it. Here's the steps I took:

  1. react-native init webview
  2. cd webview
  3. yan add react-native-webview
  4. react-native link react-native-webview
  5. react-native run-android

However, it crashes with the following content:

$ 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')

If I edit android/settings.graddle, and replace:

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

With

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

It compiles normally.

This seems like a compatibility annoyance between react-native and Windows...?

How can I fix this so it don't have to tweak this manually every time I add a package?

Lucas Bustamante
  • 15,821
  • 7
  • 92
  • 86
  • 1
    Im not sure, but I read somewhere that you should replace \ with /, can you try this and see if it works? found it: https://stackoverflow.com/questions/54434786/error-null-is-not-an-object-evaluating-c-state-unknown-index-android-bund it's not the same error, but its worth a read – kivul Feb 15 '19 at 15:19
  • @kivul's suggestion works for me. Once again tool makers forgot that some development does happen on Windows machines. – batjko Mar 12 '19 at 00:06

0 Answers0