aws-amplify login fails after eas build

hello every one, when using managed work flow all goes good in my app

  • “expo”: “~43.0.2”,

  • “aws-amplify”: “^4.3.6”,

  • “aws-amplify-react-native”: “^6.0.1”,

  • “eas-cli”:“0.38.1”

but after running eas build and install the app on android and try to login, I get this message “could not find a native getrandombase64 implementation. validate that amazon-cognito-identity-js is linked” tried to google it and apparently I need to install amazon-cognito-identity-js which is impossible since I am using expo cli it only works in react-native cli any one knows what to do?

you will need to install amazon-cognito-identity-js if you are using cognito. it’s implicitly included in expo managed apps in expo go / expo build, but because eas build only includes libraries in your package.json it’s necessary to include in this context

edit: i updated the mirgation docs to clarify this - [docs] Add note about amazon-cognito-identity-js · expo/expo@7e5b456 · GitHub

2 Likes

Where did you see this? EAS Build allows you to install many things that you would not have been able to use in a Managed Expo app previously.


sorry, amazon-cognito-identity-js was installed but here is what i get when i try eas buil android, any help?

If this is running in CI then you need to run amplify init and amplify pull on your specific environment so that amplify recreates the aws-exports file

the file is there in my source codes but I don’t know why it showing me that error coz locally it’s even working

As far as I know eas uses your .gitignore to ignore files(in this case aws-exports.js), you can override it by using a .easignore file

Mine looks as follows:

node_modules
.expo
.keys

#amplify-do-not-edit-begin
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/logs
amplify/mock-data
amplify/backend/amplify-meta.json
amplify/backend/awscloudformation
amplify/backend/.temp
build/
dist/
node_modules/
awsconfiguration.json
amplifyconfiguration.json
amplifyconfiguration.dart
amplify-build-config.json
amplify-gradle-config.json
amplifytools.xcconfig
.secret-*
**.sample
#amplify-do-not-edit-end
1 Like

Hi, I have been finding the way to add the amazon-cognito-identity-js to my managed expo workflow. Is there a doc that I could refer to?

1 Like

Are there any specific instructions for doing this linkage? Do you simply import?

@vuon0029, @pprioletti

Here are the React Native installation instructions for amazon-cognito-identity-js. For Expo with EAS Build the instructions are even simpler:

Install for React Native

See Using NPM and Webpack for more information on NPM.

  • Install and add to your dependencies the Amazon Cognito Identity SDK for JavaScript:
npm install --save amazon-cognito-identity-js

For Expo, do the above or if you use yarn then use the following instead:

yarn add amazon-cognito-identity-js
  • Install react-native-cli if you have not already:
npm install -g react-native-cli

The above is not necessary with Expo.

  • Link the native modules to your project:
react-native link amazon-cognito-identity-js

The above is not necessary with Expo.

EDIT:
As notbrent says, amazon-cognito-identity-js is included in Expo Go and in apps built with expo build, so this should work OK in Expo Go. Usually when you install dependencies like this which have native code and build with EAS Build, the app will not work in Expo Go or when built with expo build.

So for other similar libraries, instead of using Expo Go you would need to build a custom dev client and install that on your phone/emulator/simulator.