Closed ghost closed 7 years ago
@ER1011 i think react-native link
does a better job
Using RN 0.51.0 gave me the same error:
undefined is not an object (evaluating 'RNRandomBytes.seed') - Android.
{
"name": "EvolutionApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"assert": "^1.1.1",
"browserify-zlib": "^0.1.4",
"buffer": "^4.9.1",
"console-browserify": "^1.1.0",
"constants-browserify": "^1.0.0",
"crypto": "^1.0.1",
"dns.js": "^1.0.1",
"domain-browser": "^1.1.1",
"events": "^1.0.0",
"https-browserify": "0.0.1",
"moment": "^2.19.4",
"path-browserify": "0.0.0",
"process": "^0.11.0",
"querystring-es3": "^0.2.1",
"react": "16.0.0",
"react-native": "0.51.0",
"react-native-crypto": "^2.1.0",
"react-native-extended-stylesheet": "^0.8.0",
"react-native-facebook-login": "^1.6.0",
"react-native-http": "github:tradle/react-native-http#834492d",
"react-native-jwt": "^1.0.0",
"react-native-level-fs": "^3.0.0",
"react-native-local-storage": "^1.5.2",
"react-native-os": "^1.0.1",
"react-native-randombytes": "^3.0.0",
"react-native-tcp": "^3.2.1",
"react-native-udp": "^2.1.0",
"react-native-vector-icons": "^4.4.2",
"react-navigation": "^1.0.0-beta.21",
"readable-stream": "^1.0.33",
"stream": "^0.0.2",
"stream-browserify": "^1.0.0",
"timers-browserify": "^1.0.1",
"tty-browserify": "0.0.0",
"url": "^0.10.3",
"util": "^0.10.3",
"vm-browserify": "0.0.4"
},
"devDependencies": {
"babel-jest": "21.2.0",
"babel-preset-react-native": "4.0.0",
"jest": "21.2.1",
"react-test-renderer": "16.0.0"
},
"jest": {
"preset": "react-native"
},
"react-native": {
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"http": "react-native-http",
"https": "https-browserify",
"os": "react-native-os",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tty": "tty-browserify",
"vm": "vm-browserify",
"tls": false
},
"browser": {
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"http": "react-native-http",
"https": "https-browserify",
"os": "react-native-os",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tty": "tty-browserify",
"vm": "vm-browserify",
"tls": false
}
}
I made a fresh installation using yarn 1.3.2m and i also tried with react-native link
and with rnpm link
I'm using Windows 10 64 bit with node 8.9.1. I tried also installing packages using npm 5.6.0.
Error appear when i import react-native-jwt
I had this problem, too, and react-native link
did not fix it. Adding the missing things to MainApplication.java according to @ER1011's instructions worked for me (thanks!). Using RN 0.49.5.
I had to end up upgrading to the latest react-native-cli and react-native to get this error to go away.
I am experiencing this issue on Android. However, the fix that @ER1011 has suggested is redundant, as this is already the case.
package.json
"react": "16.2.0",
"react-native": "0.53.0",
"react-native-crypto": "^2.1.2",
"react-native-randombytes": "^3.0.0",
_/android/app/src/main/java/com/
import com.bitgo.randombytes.RandomBytesPackage;
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RandomBytesPackage(),
);
}
This works as expected on iOS. But when I try to run this on an Android device, I am getting the following error.
@craigcoles can you check if this example project works for you on Android? https://github.com/mvayngrib/rn-randombytes-test
@mvayngrib Will test it now.
@mvayngrib That appears to work as expected. I am unsure as to what is causing the issue in my build. I am using a newer version of RN.
@craigcoles maybe you can upgrade https://github.com/mvayngrib/rn-randombytes-test to your version of RN first, and see if it breaks? Maybe that'll give one of us a hint.
@mvayngrib That appears to work also. With regards to that app I am building, I am also using react-native-threads, so not sure whether this could be part of the issue?
@craigcoles sorry, no idea about that one. Maybe the library didn't get linked correctly on android? Try linking it manually and see if it helps
@mvayngrib No worries. I will do some digging and report back 👍
@craigcoles awesome, thanks!
I'm experiencing the same issue, but on iOS. Even after running react-native link, it still seems to be undefined.
Haven't tested yet on Android, but will make some notes when I do.
"react": "16.0.0-alpha.12", "react-native": "0.45.1", "react-native-crypto": "^2.1.2", "react-native-randombytes": "^3.0.0",
@ER1011 Thanks man that totally worked for me. Thanks for saving me time.
Is there a "manual install" workaround like this for unejected create-react-native-app?
@Taylor123 Have you find a solution? I have same issue.
Also having this issue on Android. @craigcoles -- same thing.
have used react-native link
and the imports and packages are all in mainjava
...
"dependencies": {
"@expo/vector-icons": "^6.3.1",
"@pusher/chatkit": "^0.7.12",
"asyncstorage-down": "^4.0.1",
"axios": "^0.18.0",
"eslint": "^4.0.0",
"events": "^3.0.0",
"https-browserify": "^1.0.0",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.0",
"process": "^0.11.10",
"prop-types": "^15.6.2",
"react": "16.3.1",
"react-native": "~0.55.2",
"react-native-button": "^2.3.0",
"react-native-crypto": "^2.1.2",
"react-native-dotenv": "^0.1.1",
"react-native-elements": "^0.19.1",
"react-native-gifted-chat": "^0.4.3",
"react-native-keyboard-aware-scroll-view": "^0.5.0",
"react-native-level-fs": "^3.0.1",
"react-native-modal": "^6.1.0",
"react-native-randombytes": "^3.4.0",
...
my react native version is actually 55.4
@ortonomy does the sample project linked above work for you?
I'm experiencing the same issue, but on iOS. Even after running react-native link, it still seems to be undefined.
Haven't tested yet on Android, but will make some notes when I do.
"react": "16.0.0-alpha.12", "react-native": "0.45.1", "react-native-crypto": "^2.1.2", "react-native-randombytes": "^3.0.0",
are you find a solution for this sir?
"react-native": "0.56.0", "react-native-randombytes": "^3.5.1",
react-native link doesn't always link this module. Maybe it's the directory structure. Meanwhile, you can link it manually in Xcode, see React Native docs on linking libraries
In case you are having this issue on ANDROID:
I'm using RN 041.2
rnpm link react-native-randombytes does not seem to do what it's supposed to do. You get the error because the module is not linked.
The part that is missing is what goes in MainApplication.java, specifically: 1) add this at the top of the file: import com.bitgo.randombytes.RandomBytesPackage; 2) add this to the list of packages: new RandomBytesPackage()
Hope this helps!