Open JUDOKICK opened 4 years ago
Did you found a solution for this?
No unfortunately. I ended up just using the native crypto libraries in Android to get it to work. Very frustrating issue though.
@JUDOKICK I'm having the same issue, please help is there any workaround? I spent 5days on it but that issue is still there how can I fix this problem? What did you in your case? how did you implement a native crypto library in android?
Using Java and linking the two with an ejected version of my app. There is no fix for this. React-Native won't support new NodeJs libraries. This used to work on older versions. But now all the libraries that end up needing the NodeJs libraries use newer versions. Unless you feel like digging through your dependencies and locking each specific version just to get this to work. I highly suggest ejecting and using the native java/swift libraries.
ok, thanks may I know how can I use native libraries? Can you share a code example like you did it would be really helpful for me? Please help
Unfortunately, you're going to have to look on your own for examples on how to do that as it's different for every implementation.
On Fri, 1 May 2020, 11:56 Yasir Shah, notifications@github.com wrote:
ok, thanks may I know how can I use native libraries? Please help
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mvayngrib/react-native-randombytes/issues/40#issuecomment-622343810, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELX7GYLUNWOBWD3A753LBLRPKTFXANCNFSM4KSRSW2A .
I found a temporary solution to this problem well maybe not temporary but its kind of hack
To add missing native module you need to manually add specific files from this repo to your project
For example, if you need this to work on Android, you have to copy two files in android/src/main/java/com/bitgo/randombytes/ You need to use those two files like if you wanted to implement your own native modules; you can find guide how to connect everything right here
And after that, in debug mode I was able to see that native module is not null and everything works fine
In my case, I had react-native-randombytes installed. Maybe you did the react-native link
or react-native link react-native-randombytes
as me. I opened podfile and it did link for us. However, if you opened pod.lock and looked for it, it did not auto install for us. I went to ios folder and pod install
, it finally works. this issue wasted me like 5 days.
I think expo is the problem here. I tried setting it up with this boilerplate where you can specify if you want to use expo for your project or not. Without expo it is working fine and with expo it fails with this error.
Just wanted to leave this comment in case it helps anyone pin down the issue.
This was a problem for me while working with expo SDK and I needed rn-nodeify:
expo install react-native-randombytes
I think that by running the 3rd command with expo and not with rn-nodeify it linked the needed dependencies.
Update: It created another problem, so didn't fix it. I think metro config fixed the problem.
I have an expo application, I added the import statement to my code and suddenly faced this error ? is there anyway to make it work with expo ?
I fixed it by opening the file explorer and explicitly searched for all the files inside my project that contain "RNRandomBytes.seed" text in them and then, inside all of the file indexes found, I just replace the init() function with this code:
function init () {
if (RNRandomBytes) {
if (RNRandomBytes.seed) {
let seedBuffer = toBuffer(RNRandomBytes.seed)
addEntropy(seedBuffer)
} else {
seedSJCL()
}
}
}
I still have this issue with expo
3. expo install react-native-randombytes
Can you elaborate on exactly how this fixed your issue please? I have the same error and tried this hacky approach only to have the app fail in a similar fashion - "o.default.randomBytes is not a function"
3. expo install react-native-randombytes
Does your app not need RNRandomBytes? Do you do any crypto operations in your app?
I am struggling to get this fixed.
In my case, I had react-native-randombytes installed. Maybe you did the
react-native link
orreact-native link react-native-randombytes
as me. I opened podfile and it did link for us. However, if you opened pod.lock and looked for it, it did not auto install for us. I went to ios folder andpod install
, it finally works. this issue wasted me like 5 days.
You are a god among men
I am currently unable to use react-native-crypto because randombytes throws this null error. I am using an ejected Expo, SDK35, and all steps followed from react-native-crypto I have linked correctly, used rn-nodeify and imported the shim file and still it is not working.
I have tried possibly all combinations of steps and procedures for installations and none of them seem to work for the latest expo/react-native sdks.
It has to do with this section of code
let sjcl = require('sjcl') `let RNRandomBytes = require('react-native').NativeModules.RNRandomBytes
function noop () {}
function toBuffer (nativeStr) { return new Buffer(nativeStr, 'base64') }
function init () { if (RNRandomBytes.seed) { let seedBuffer = toBuffer(RNRandomBytes.seed) addEntropy(seedBuffer) } else { seedSJCL() } }
The error is line 15
if (RNRandomBytes.seed)` meaning that it never gets initialized somehow