react-native-webview: Error with latest version on Android (Crypto package not exist for RN)
So I keep getting following error:
Which can be easily solved by adding react-native-get-random-values package and importing it from index.js of my project.
Thah being said, I don’t think it’s a good practive to let users deal with this kind of thing. Are UUID and node’s crypto packages required to run webview?
Thanks.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 41
- Comments: 55 (5 by maintainers)
Try to move import at very top of the index.js file
I did https://github.com/react-native-community/react-native-webview/pull/1334 🙌
When I
yarn add react-native-get-random-values, got a new problem, null is an object(evaluating ‘RNGetRandomValues.getRandomBase64’)As @Sine99 said, back to v9.1.1, everything are fine.
Instead of using uuid package we probably should use something like this:
@dev20190101 you probably forgot to rebuild (
react-native run-android) as your error indicates, that the native module (couterpart to the js part of react-native-get-random-values) is not available yet. If you already did that, trycd android && ./gradlew cleanfirst.I don’t think your comment helps
Thanks @artyorsh!
I just wonder why the new version was released when it does not work at all?
not working…can you tell me the solution detail? @sebinq i have installed the
react-native-get-random-valuesin my proj , and addimport 'react-native-get-random-values';in my index.js file and react-native-webview index.js file ,someting wrong? my proj :webview proj:
Reproduced on RN webview 9.1.3 and RN 0.62.2, on both debug and release builds.
And confirmed workaround with
I had the same problem when I use “react-native-webview”: “9.2.1”, but I change it to “react-native-webview”: “9.0.2” and it works fine.
This worked for me. I prefer creating a (hopefully temporary) patch over adding another module.
To expand a bit more.
uuid.js.If you have
patch-packagesetup, the patch will be applied when younpm install.Agreed. I’ve had to roll back to 9.1.1 which seems to be the last working version that doesn’t have this issue. If this package now requires a new package to be installed, it really should be explained in the setup instructions and the release notes.
reset cache, have a try.
Same issue here, I reverted back to v9.1.1 till this bug is fixed …Not facing any issue so far.
thanks!! it working now!
As mentioned above a temporary fix is to use patch-package. Thanks to @DomiR . Here is my patch that works fine:
patches/react-native-webview+9.2.1.patchMaybe I add tests to my app so I can avoid all non-tested dependencies.
add tests and this won’t happen anymore
For me it works when the import is in the first line of index.js and you rebuild everything:
rm -rf ~/.gradle/caches/ delete the Android build directory restart Metro
@ritesh-malav I had the same issue, when I didn’t install it by expo command. before expo: “react-native-webview”: “^9.2.1” after expo: “react-native-webview”: “8.1.1”
maybe try 8.1.1 version !
✅ If you are using Expo, please “expo install react-native-webview”
Doesn’t work for me. I tried adding
react-native-get-random-valuesusingnpm install --save react-native-get-random-valuesand I still see the same issue.Same issue with the setup “react-native”: “0.62.2”, “react-native-get-random-values”: “1.3.1”, “react-native-webview”: “9.2.0”
Same thing for 9.1.4 and react-native 0.61.5