async-storage: NativeModule: AsyncStorage is null.

Current behavior

blob:http://localhost:8081/f71b1a49-45d9-440e-b076-cf2bd5be26c1:23126 [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.

To fix this issue try these steps:

• Run react-native link @react-native-community/async-storage in the project root.

• Rebuild and restart the app.

• Run the packager with --clearCache 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://github.com/react-native-community/async-storage/blob/LEGACY/docs/Jest-integration.md

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

Expected behavior

Repro steps

Environment

“dependencies”: { “@ant-design/icons-react-native”: “^1.0.2”, “@ant-design/react-native”: “^3.1.9”, “@react-native-community/async-storage”: “^1.5.1”, “babel-plugin-import”: “^1.12.0”, “react”: “16.8.6”, “react-native”: “0.60.0”, “react-native-button”: “^2.4.0”, “react-native-device-info”: “^2.2.2”, “react-native-loading-spinner-overlay”: “^1.0.1”, “react-native-message-bar”: “^2.0.10”, “react-native-router-flux”: “^4.0.6” }, “devDependencies”: { “@babel/core”: “^7.5.0”, “@babel/runtime”: “^7.5.0”, “@react-native-community/eslint-config”: “^0.0.5”, “babel-jest”: “^24.8.0”, “eslint”: “^6.0.1”, “jest”: “^24.8.0”, “metro-react-native-babel-preset”: “^0.55.0”, “react-test-renderer”: “16.8.6” }, “jest”: { “preset”: “react-native” }

  • Async Storage version:
  • React-Native version:
  • Platform tested:
  • Logs/Error that are relevant:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 25
  • Comments: 51 (16 by maintainers)

Most upvoted comments

I believe this might be due RN 0.60. Please refer to unlinking instruction here and let me know if it helped.

it’s not linked , and I already tried to re-unlink it , but same issue

Edit : and to be more specific this issue is on Android , IOS works fine.

I have the same error on Android. I have an “ejected” app with Expo SDK v33 (ReactNative v0.59).

I was trying to use react-native-qrcode-scanner, which depends on react-native-permissions, which depends on async-storage.

I linked it with react-native link @react-native-community/async-storage but I still have the same error.

// MainApplication.java
...
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import org.reactnative.camera.RNCameraPackage;

...

  public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
            new AsyncStoragePackage(),
            new RNCameraPackage()
            ...

@SaeedZhiany Can you check if the module is properly linked? Check MainApplication.java file, and look for AsyncStorage module implementation. Linking guide can be helpful here

@SaeedZhiany link command is doing that for ya. It detects your project type (Pods or not) and does the rest for ya.

Have you tried adding:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name == "React"
          target.remove_from_project
        end
      end
    end

To your Podfile?

@msqar Please refer to change diff between 0.59.10 and 0.60.4 to see how to adapt your project.

thanks.

No worries, I resolved this and have since moved on to more challenging problems…its like it never ends.

yes, I finally link the project manually and my problem has been fixed, but I was expecting that react-native link or pod install do that for me automatically, but none of them does.

Rofl sorry @Krizzu , it seems that I forget the pod install indeed. I confirm it is working on a fresh install for iOS and Android for react-native 0.60.3. Thanks 😃

@PierreCapo Did you run pod install?

Hello, I have the same issue. It works well on Android but I got this error on iOS. It happened with a fresh install (react-native 0.60.3).

I have the same on IOS