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

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

Closed puneetkumarkaushik closed 9 months ago

puneetkumarkaushik commented 1 year ago

Getting following issue when using @react-native-async-storage/async-storage library. It is happening only when I'm running the project in ios simulator. It's working fine in android. I have tried 1.18.2, 1.18.1, 1.18.0, 1.17.11 versions. I have tried steps mentioned in error as well.

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

I'm using following dependencies: "dependencies": { "@react-native-async-storage/async-storage": "^1.18.0", "@react-native-firebase/app": "^18.0.0", "@react-native-masked-view/masked-view": "^0.2.9", "@react-navigation/native": "^6.1.6", "@react-navigation/native-stack": "^6.9.12", "@react-navigation/stack": "^6.3.16", "firebase": "^9.22.2", "react": "18.1.0", "react-native": "0.70.6", "react-native-animatable": "^1.3.3", "react-native-gesture-handler": "^2.9.0", "react-native-safe-area-context": "^4.5.3", "react-native-screens": "^3.14.0", "react-native-shared-element": "^0.8.8", "react-native-vector-icons": "^9.2.0", "react-navigation-shared-element": "^3.1.3" },

muhammedilan commented 1 year ago

i have the same problem

puneetkumarkaushik commented 1 year ago

I was getting this error when I called AsyncStorage functions e.g. AsyncStorage.setItem(key, value);. Now I'm using Context API, the error is gone. It can work with redux also.

muhammedilan commented 1 year ago

I was getting this error when I called AsyncStorage functions e.g. AsyncStorage.setItem(key, value);. Now I'm using Context API, the error is gone. It can work with redux also.

I got this error while installing it in an existing project, but when I installed another application (npx react-native@latest init) and installed asyncStorage on it, it worked

mocon commented 1 year ago

We are having this same issue as well, from within our Jest tests.

Edit: Fixed the issue in our project by bumping the version:

...
"@react-native-async-storage/async-storage": "~1.18.2"
...
liu1700 commented 1 year ago

I have the same problem

shixiaoquan commented 1 year ago

I was getting this error when I called AsyncStorage functions e.g. AsyncStorage.setItem(key, value);. Now I'm using Context API, the error is gone. It can work with redux also.

I got this error while installing it in an existing project, but when I installed another application (npx react-native@latest init) and installed asyncStorage on it, it worked

have you fixed this issue

810861180 commented 11 months ago

I installed version 1.17.11 to fix the problem

github-actions[bot] commented 9 months ago

This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.