async-storage: ERROR Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
What happened?
Hi everyone,
I encountered an issue with @react-native-async-storage/async-storage. When running my React Native application, I get the following error when I run it on iOS 17.5 Simulator:
ERROR Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
I have tried all the recommended solutions but the error persists:
- Uninstalled the app, rebuilt, and restarted it.
- Cleared the Metro bundler cache using the
--reset-cacheflag. - Ran
pod installin theiosdirectory (using CocoaPods). - Verified that
@react-native-async-storage/async-storageis listed as a dependency in mypackage.json. - Removed
node_modules,yarn.lock, andpackage-lock.jsonfiles. - Cleaned the yarn cache by running
yarn cache clean. - Re-installed all dependencies using
yarn installand rebuilt the project.
Environment Details
- React Native Version: “0.74.1”
- AsyncStorage Version: “^2.1.0”
- Platform: iOS
- Node.js Version: v21.7.1
- Yarn Version: 3.6.4
Expected Behavior
The app should correctly recognize the AsyncStorage NativeModule and work as expected.
Actual Behavior
The error NativeModule: AsyncStorage is null is displayed, and the app does not function correctly.
Additional Information
If there are any additional steps I could try or if there’s a known workaround, please let me know.
Thank you for your help!
Version
v2.1.0
What platforms are you seeing this issue on?
- Android
- iOS
- macOS
- Windows
- web
System Information
System:
OS: macOS 15.1.1
CPU: (14) arm64 Apple M3
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 21.7.1
path: /opt/homebrew/bin/node
Yarn:
version: 3.6.4
path: ~/DevProject/node_modules/.bin/yarn
npm:
version: 10.5.0
path: /opt/homebrew/bin/npm
Watchman:
version: 2024.03.25.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.1
- iOS 18.1
- macOS 15.1
- tvOS 18.1
- visionOS 2.1
- watchOS 11.1
Android SDK:
API Levels:
- "30"
- "31"
- "33"
- "33"
- "34"
Build Tools:
- 30.0.3
- 33.0.0
- 33.0.2
- 34.0.0
System Images:
- android-30 | Google APIs ARM 64 v8a
- android-33 | Google APIs ARM 64 v8a
- android-33 | Google APIs ATD ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11330709
Xcode:
version: 16.1/16B40
path: /usr/bin/xcodebuild
Languages:
Java:
version: 18.0.2.1
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.74.1
wanted: 0.74.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Steps to Reproduce
Here’s an updated issue description with the Steps to Reproduce section:
Description of the Issue
I encountered an issue with @react-native-async-storage/async-storage. When running my React Native application, I get the following error:
ERROR Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
Steps to Reproduce
-
Create a new React Native project or use an existing one.
-
Install
@react-native-async-storage/async-storageby running:yarn add @react-native-async-storage/async-storage -
On iOS:
- Navigate to the
iosfolder and runpod install. - Build and run the app using
yarn run-ios.
- Navigate to the
-
Attempt to use
AsyncStoragein the app. Example:import AsyncStorage from '@react-native-async-storage/async-storage'; const storeData = async () => { try { await AsyncStorage.setItem('key', 'value'); } catch (e) { console.log(e); } }; storeData();
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 17
@AKA-Muhannad I did but I am having same on android emulator, otherwise it is working on ios side
Hi Guys, Did anyone tried to change the simulator?
Downgrade to 0.76.3, and full rebuild. Need merge of: https://github.com/facebook/react-native/pull/48156