Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 5 tasks
AKA-Muhannad opened this issue Dec 2, 2024 · 15 comments
Open
1 of 5 tasks
Labels
bug Something isn't working

Comments

@AKA-Muhannad
Copy link

AKA-Muhannad commented Dec 2, 2024

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:

  1. Uninstalled the app, rebuilt, and restarted it.
  2. Cleared the Metro bundler cache using the --reset-cache flag.
  3. Ran pod install in the ios directory (using CocoaPods).
  4. Verified that @react-native-async-storage/async-storage is listed as a dependency in my package.json.
  5. Removed node_modules, yarn.lock, and package-lock.json files.
  6. Cleaned the yarn cache by running yarn cache clean.
  7. 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

  1. Create a new React Native project or use an existing one.

  2. Install @react-native-async-storage/async-storage by running:

    yarn add @react-native-async-storage/async-storage
  3. On iOS:

    • Navigate to the ios folder and run pod install.
    • Build and run the app using yarn run-ios.
  4. 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();
@AKA-Muhannad AKA-Muhannad added the bug Something isn't working label Dec 2, 2024
@abduljamalbasha
Copy link

abduljamalbasha commented Dec 3, 2024

I encountered this issue with Android
@react-native-async-storage/[email protected].
When running my React Native application

Please help me to resolve this issue.

Screenshot 2024-12-03 at 1 02 26 PM

What platforms are you seeing this issue on?

  • Android

@bytemtek
Copy link

bytemtek commented Dec 4, 2024

Same here+

@Doraemon-v
Copy link

Same here+ for Android.

@huan415201
Copy link

Same here, on Android
"@react-native-async-storage/async-storage": "^2.1.0"
"react-native": "0.76.4"

@Dallas62
Copy link

Dallas62 commented Dec 7, 2024

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

@avj3395
Copy link

avj3395 commented Dec 8, 2024

Same here, on Android
"@react-native-async-storage/async-storage": "^2.1.0"

@MuhammadrizoDeveloper
Copy link

MuhammadrizoDeveloper commented Dec 8, 2024

Same here, Android

"@react-native-async-storage/async-storage": "1.23.1"

Update: even with 2.1.0

@Dallas62
Copy link

Dallas62 commented Dec 8, 2024

@MuhammadrizoDeveloper
Copy link

@MuhammadrizoDeveloper @avj3395 #1165 (comment)

But I'm on react-native: 0.76.3

@shovel-kun
Copy link

@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.

@Dallas62
Copy link

Dallas62 commented Dec 9, 2024 via email

@AnassHmida
Copy link

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.

@aiengrimran
Copy link

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

@AKA-Muhannad
Copy link
Author

Hi Guys,
Did anyone tried to change the simulator?

@aiengrimran
Copy link

@AKA-Muhannad I did but I am having same on android emulator, otherwise it is working on ios side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests