react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.62k stars 459 forks source link

Async-storage issue (Metamask SDK) #961

Closed opeerator closed 1 year ago

opeerator commented 1 year ago

What happened?

Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.

To fix this issue try these steps:

• Rebuild and restart the app.

• Run the packager with --reset-cache flag.

• If you are using CocoaPods on iOS, run pod install in the ios directory and then rebuild and re-run the app.

• If this happens while testing with Jest, check out docs how to integrate AsyncStorage with it: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest

If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-async-storage/async-storage/issues , js engine: hermes

Version

1.17.11

What platforms are you seeing this issue on?

System Information

System:
    OS: Linux 5.19 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 1.41 GB / 19.42 GB
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 14.21.3 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 6.14.18 - /usr/bin/npm
    Watchman: 20230416.213759.0 - /usr/local/bin/watchman
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: AI-222.4459.24.2221.9862592
  Languages:
    Java: 11.0.18 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.7 => 0.71.7 
  npmGlobalPackages:
    *react-native*: Not Found

Steps to Reproduce

Hi there,

I'm Using the metamask sdk on a react-native app (0.71.7) but on build I face the following error. Does anyone have an idea why this is happening with this version of react-native. The example they provided in their documentation with react-native (0.67.3) builds with success.

Regards

mateoguzmana commented 1 year ago

Adding the jest mocks fixes this. See: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest/