ERROR Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
AKA-Muhannad opened this issue · 15 comments
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-cache
flag. - Ran
pod install
in theios
directory (using CocoaPods). - Verified that
@react-native-async-storage/async-storage
is listed as a dependency in mypackage.json
. - Removed
node_modules
,yarn.lock
, andpackage-lock.json
files. - Cleaned the yarn cache by running
yarn cache clean
. - Re-installed all dependencies using
yarn install
and 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-storage
by running:yarn add @react-native-async-storage/async-storage
-
On iOS:
- Navigate to the
ios
folder and runpod install
. - Build and run the app using
yarn run-ios
.
- Navigate to the
-
Attempt to use
AsyncStorage
in 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();
Same here+
Same here+ for Android.
Same here, on Android
"@react-native-async-storage/async-storage": "^2.1.0"
"react-native": "0.76.4"
Same here, on Android "@react-native-async-storage/async-storage": "^2.1.0" "react-native": "0.76.4"
Downgrade to 0.76.3, and full rebuild.
Need merge of: facebook/react-native#48156
Same here, on Android
"@react-native-async-storage/async-storage": "^2.1.0"
Same here, Android
"@react-native-async-storage/async-storage": "1.23.1"
Update: even with 2.1.0
But I'm on react-native: 0.76.3
@MuhammadrizoDeveloper Did you upgrade to RN 0.76.4 and then downgrade back to 0.76.3?
Deleting node_modules
and android
for some reason did not fix the problem for me, so I had to delete my project folder and clone from my last commit.
Hey guys , so after some investigation i found that a breaking change was added in 0.76.4 , and this commit is the source :
facebook/react-native@8886f15#diff-c27f12d86f04bebb804a683579663a8e431cd1d149ed42e38acaada75365c440
revert this change an everything shall work as expected.
Hi everyone, What should I do, if this issue is related to react-native or async storage.
Can anybody guide either I should wait or perform some changes I have latest react-native
Hi Guys,
Did anyone tried to change the simulator?
@AKA-Muhannad I did but I am having same on android emulator, otherwise it is working on ios side