question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: null is not an object (evaluating ‘_ExpoRandom.default.getRandomBytes’)

See original GitHub issue

Summary

Im use expo-auth-session/providers/google with expo dev client

monorepo

expo sdk 44

install : expo install expo-auth-session expo-random expo-web-browser

open app crash show

TypeError: null is not an object (evaluating ‘_ExpoRandom.default.getRandomBytes’)

im use * See the guide for more info on usage: Google Authentication.

Managed or bare workflow? If you have made manual changes inside of the ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android, iOS

Package versions

No response

Environment

Expo CLI 5.2.0 environment info: System: OS: macOS 11.4 Shell: 5.8 - /bin/zsh Binaries: Node: 16.14.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 8.3.1 - /usr/local/bin/npm Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: API Levels: 23, 28, 29, 30, 31 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0 System Images: android-30 | Google APIs ARM 64 v8a, android-30 | Google Play ARM 64 v8a, android-S | Google APIs ARM 64 v8a, android-S | Google APIs Intel x86 Atom_64 IDEs: Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild npmPackages: @expo/metro-config: ^0.3.11 => 0.3.12 expo: ^44.0.6 => 44.0.6 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 react-navigation: ^4.4.4 => 4.4.4 npmGlobalPackages: eas-cli: 0.17.0 Expo Workflow: managed

Reproducible demo

// expo install expo-web-browser expo-auth-session expo-random import { StatusBar } from ‘expo-status-bar’; import React from ‘react’; import { StyleSheet, View, Text, Image, Button } from ‘react-native’; import * as Google from ‘expo-auth-session/providers/google’; import * as WebBrowser from ‘expo-web-browser’;

WebBrowser.maybeCompleteAuthSession();

export default function App() { const [accessToken, setAccessToken] = React.useState(); const [userInfo, setUserInfo] = React.useState(); const [message, setMessage] = React.useState();

const [request, response, promptAsync] = Google.useAuthRequest({ androidClientId: “694235095257-fkbf1u81sm5ii76om74j5b7h8u4v2m7a.apps.googleusercontent.com”, iosClientId: “694235095257-qnub27n3o6s0e3lo1sneio03o6ka5k9m.apps.googleusercontent.com”, expoClientId: “694235095257-7t7h7mv877d2jfu7r508ct1egmesbqdm.apps.googleusercontent.com” });

React.useEffect(() => { setMessage(JSON.stringify(response)); if (response?.type === “success”) { setAccessToken(response.authentication.accessToken); } }, [response]);

async function getUserData() { let userInfoResponse = await fetch(“https://www.googleapis.com/userinfo/v2/me”, { headers: { Authorization: Bearer ${accessToken}} });

userInfoResponse.json().then(data => {
  setUserInfo(data);
});

}

function showUserInfo() { if (userInfo) { return ( <View style={styles.userInfo}> <Image source={{uri: userInfo.picture}} style={styles.profilePic} /> <Text>Welcome {userInfo.name}</Text> <Text>{userInfo.email}</Text> </View> ); } }

return ( <View style={styles.container}> {showUserInfo()} <Button title={accessToken ? “Get User Data” : “Login”} onPress={accessToken ? getUserData : () => { promptAsync({useProxy: false, showInRecents: true}) }} /> <StatusBar style="auto" /> </View> ); }

const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: ‘#fff’, alignItems: ‘center’, justifyContent: ‘center’, }, userInfo: { alignItems: ‘center’, justifyContent: ‘center’, }, profilePic: { width: 50, height: 50 } });

Stacktrace (if a crash is involved)

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thedoublejaycommented, May 20, 2022

I have the same issue as @emiliogaines. Same packages versions, setup etc. Only happened on SDK 45, iOS production build (from TestFlight). Cannot reproduce on Expo builds. I’ve tried rebuilding it multiple times. Same result.

It works when downgrading with expo-random@12.1.2

1reaction
bondPiyapancommented, Mar 25, 2022

@byCedric thx you.

Im use $ expo install expo-random but forget import expo-random in dependencies with package.json project in monorepo.

This makes the lib unable to link.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: null is not an object (evaluating 'RNRandomBytes ...
1 Answer 1 ; ReactMethod public void randomBytes ; invoke(null, getRandomBytes ; getRandomBytes(int size) { SecureRandom ...
Read more >
TypeError: null is not an object (evaluating ... - Expo forums
Hello, i have upgraded my project to ExpoSDK 46. On the web everything works well, but when trying to run the project on...
Read more >
typeerror: null is not an object (evaluating 'response ... - You.com
The response of your ajax call is not an object, it is evaluated as null. ... import {NativeModules} from 'react-native'; export default NativeModules....
Read more >
How To Fix TypeError null is not an object (evaluating ...
React Native Tutorial - This Video ShowsHow To Fix TypeError null is not an object ( evaluating 'dispatcher.useState) TypeError react native ...
Read more >
Source - GitHub
Package-specific changes not released in any SDK will be added here just before ... Fixed `setUserIdAsync` throwing error on Android when `null` is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found