TypeError: null is not an object (evaluating ‘_ExpoRandom.default.getRandomBytes’)
See original GitHub issueSummary
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:
- Created a year ago
- Comments:10 (2 by maintainers)
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
@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.