Async-storage: NativeModule: AsyncStorage is null.

Created on 10 Jul 2019  Β·  51Comments  Β·  Source: react-native-async-storage/async-storage

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:
bug

Most helpful comment

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()
            ...

All 51 comments

same issue here

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

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.

@AbanoubNassem Can you confirm that AsyncStorage is unlinked on android? Is it visible in MyApplication package list?

yes i comfirm

发θ‡ͺζˆ‘ηš„iPhone

------------------ Original ------------------
From: Krzysztof Borowy notifications@github.com
Date: Wed,Jul 10,2019 6:05 PM
To: react-native-community/async-storage async-storage@noreply.github.com
Cc: python_samllbird 467196574@qq.com, Author author@noreply.github.com
Subject: Re: [react-native-community/async-storage] NativeModule: AsyncStorage is null. (#158)

@AbanoubNassem Can you confirm that AsyncStorage is unlinked on android? Is it visible in MyApplication package list?

β€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@AbanoubNassem Can you confirm that AsyncStorage is unlinked on android? Is it visible in MyApplication package list?

Yes I can confirm , it's not linked , and it's not in MainApplication packages list


import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.Nullable;

public class MainApplication extends NavigationApplication {

    @Override
    protected ReactNativeHost createReactNativeHost() {
        return new NavigationReactNativeHost(this) {
            @Override
            protected String getJSMainModuleName() {
                return "index";
            }
        };
    }

    @Override
    public boolean isDebug() {
        return BuildConfig.DEBUG;
    }

    @Nullable
    @Override
    public List<ReactPackage> createAdditionalReactPackages() {
        List<ReactPackage> packages = new ArrayList<>();

        return packages;
    }
}

Any repro steps for this one? Does it happen with a fresh project?

I have the same on IOS

Adding my comment mostly to get notifications on updates. I got this issue on iOS but not on android for some reason. I unlinked all my libraries, ran pod install after removing both the Pods folder and the Podfile.lock and I still get that error.

Version is 1.5.1

I'd need some help to get it to reproduce - does it happen on a fresh project? Is there a repo with the issue I could look into?

Found my problem! I didn't fully change my Podfile and still had the postinstall stuff in there from before upgrading to 0.60.0.

Changing the bottom section to

  target 'RnDiffAppTests' do
    inherit! :search_paths
    # Pods for testing
  end
  use_native_modules!
end
target 'RnDiffApp-tvOS' do
  # Pods for RnDiffApp-tvOS
  target 'RnDiffApp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

Made it work properly. Maybe @ithustle has the same issue?

I'm seeing this in 0.59.10 too. Replaced the one in the RN package to get rid of the depreciation warning after upgrade.

Installed it as suggested, but getting this on both ios and android.

i guess mybe some one of pakages is wrong . i will try

发θ‡ͺζˆ‘ηš„iPhone

------------------ Original ------------------
From: trickeyd notifications@github.com
Date: Fri,Jul 12,2019 10:34 PM
To: react-native-community/async-storage async-storage@noreply.github.com
Cc: python_samllbird 467196574@qq.com, Author author@noreply.github.com
Subject: Re: [react-native-community/async-storage] NativeModule: AsyncStorage is null. (#158)

I'm seeing this in 0.59.10 too. Replaced the one in the RN package to get rid of the depreciation warning after upgrade.

Installed it as suggested, but getting this on both ios and android.

β€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

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

@PierreCapo Did you run pod install?

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 :)

@Krizzu
I'm using RN 0.59.10 with version 1.5.0 of this library and have the same problem

in my case, Android is fine and IOS fails.

@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

@Krizzu
As I said Android app works fine, Is MainApplication.java related to IOS builds?!

However I check it and new AsyncStoragePackage(), exists in the file

I'm still on RN 0.59.10 and I don't migrate to RN +0.60, But I'm using cocopods for my IOS project

I checked libraries folder, it seems that pod don't add RNCAsyncStorage.xcodeproj into the folder.

Sorry, I misread which platform works for ya. RNCAsyncStorage.xcodeproj should be added if not using Pods, so it's fine in your case.

Can you post Podfile here ?

Yes, here it is:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'ProjectName' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Required by RNFirebase
  pod 'Firebase/Core', '6.3.0'
  pod 'Firebase/Messaging', '6.3.0'

  # Pods for ProjectName

  pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'React', path: '../node_modules/react-native', subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTAnimation',
    'RCTActionSheet',
    'RCTBlob',
    'RCTCameraRoll',
    'RCTGeolocation',
    'RCTImage',
    'RCTPushNotification',
    'RCTSettings',
    'RCTTest',
    'RCTVibration',
    'RCTLinkingIOS'
  ]
  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

  target 'ProjectNameTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'ProjectName-tvOS' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for ProjectName-tvOS

  target 'ProjectName-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

@SaeedZhiany Have you tried steps listed in troubleshooting guide?

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.

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.

because your pod file configuration is missing the autolink feature , to fix it

edit and replace your pod file with this: -


# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'ProjectName' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

# Pods for ProjectName

  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  target 'ProjectNameTests' do
    inherit! :search_paths
    # Pods for testing
  end

use_native_modules!


end

target 'ProjectName-tvOS' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for ProjectName-tvOS

  target 'ProjectName-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

@AbanoubNassem
you mean I should replace my entire pod file with what you suggest? as you can see I use RNfirebase too but I can't see it in your configuration suggestion.

And please consider, as I mentioned I'm not ready to migrate to RN +0.60 and I still using RN 0.59.10.

Also, what is cli-platform-ios? I haven't such folder in the ../node_modules/@react-native-community/ directory, Do I should add a new dependency in my project?

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()
            ...

I don't use pod, how can i make this work? i'm struggling so bad after upgrading to RN 0.60.
It throws this error on Android only. I don't have it linked anywhere, i already did the unlink.

@AbanoubNassem Can you confirm that AsyncStorage is unlinked on android? Is it visible in MyApplication package list?

Yes I can confirm , it's not linked , and it's not in MainApplication packages list


import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.Nullable;

public class MainApplication extends NavigationApplication {

    @Override
    protected ReactNativeHost createReactNativeHost() {
        return new NavigationReactNativeHost(this) {
            @Override
            protected String getJSMainModuleName() {
                return "index";
            }
        };
    }

    @Override
    public boolean isDebug() {
        return BuildConfig.DEBUG;
    }

    @Nullable
    @Override
    public List<ReactPackage> createAdditionalReactPackages() {
        List<ReactPackage> packages = new ArrayList<>();

        return packages;
    }
}

do you still have this issue?
i've same configuration and it seems to be related with RNNavigation

@cesarm16 nope it was fixed by itself, so yeah I think it's RNNavigation

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

I'm having this issue with an ejected expo kit app on expo sdk v33.0.

My podfile looks like (as you can see I added pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'):

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'

target 'randommobileapp' do
  pod 'ExpoKit',
    :git => "http://github.com/expo/expo.git",
    :tag => "ios/2.11.2",
    :subspecs => [
      "Core"
    ],
    :inhibit_warnings => true

  # Install unimodules
  require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
  use_unimodules!(
    modules_paths: ['../node_modules'],
    exclude: [
      'expo-face-detector',
      'expo-payments-stripe',
    ],
  )

  pod 'React',
    :path => "../node_modules/react-native",
    :inhibit_warnings => true,
    :subspecs => [
      "Core",
      "ART",
      "RCTActionSheet",
      "RCTAnimation",
      "RCTCameraRoll",
      "RCTGeolocation",
      "RCTImage",
      "RCTNetwork",
      "RCTText",
      "RCTVibration",
      "RCTWebSocket",
      "DevSupport",
      "CxxBridge"
    ]
  pod 'yoga',
    :path => "../node_modules/react-native/ReactCommon/yoga",
    :inhibit_warnings => true
  pod 'DoubleConversion',
    :podspec => "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec",
    :inhibit_warnings => true
  pod 'Folly',
    :podspec => "../node_modules/react-native/third-party-podspecs/Folly.podspec",
    :inhibit_warnings => true
  pod 'glog',
    :podspec => "../node_modules/react-native/third-party-podspecs/glog.podspec",
    :inhibit_warnings => true

  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

  post_install do |installer|
    installer.pods_project.main_group.tab_width = '2';
    installer.pods_project.main_group.indent_width = '2';

    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|

      if pod_name == 'ExpoKit'
        target_installation_result.native_target.build_configurations.each do |config|
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'EX_DETACHED=1'

          # Enable Google Maps support
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'HAVE_GOOGLE_MAPS=1'
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'HAVE_GOOGLE_MAPS_UTILS=1'

        end
      end


      if ['Amplitude-iOS','Analytics','AppAuth','Branch','CocoaLumberjack','FBSDKCoreKit','FBSDKLoginKit','FBSDKShareKit','GPUImage','JKBigInteger2'].include? pod_name
      target_installation_result.native_target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
      end
      end

      # Can't specify this in the React podspec because we need to use those podspecs for detached
      # projects which don't reference ExponentCPP.
      if pod_name.start_with?('React')
        target_installation_result.native_target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
          config.build_settings['HEADER_SEARCH_PATHS'] ||= ['$(inherited)']
        end
      end

      # Build React Native with RCT_DEV enabled and RCT_ENABLE_INSPECTOR and
      # RCT_ENABLE_PACKAGER_CONNECTION disabled
      next unless pod_name == 'React'
      target_installation_result.native_target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_DEV=1'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_ENABLE_INSPECTOR=0'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'ENABLE_PACKAGER_CONNECTION=0'
      end

    end
  end
end

Then, I run pod install from my ios directory, and I can see it appearing to build successfully in XCode. However, I get NativeModule: AsyncStorage is null. I've tried every permutation of cleaning and rebuilding, and I can't get it to work. Any idea what I'm doing wrong here? I followed the troubleshooting steps you've linked here as well, but they didn't help.

Thanks!

I am getting this error on ios only.

I am using "@react-native-community/async-storage": "1.5.1".

and inside of src/services/LocalStorage.js file:

import AsyncStorage from "@react-native-community/async-storage";

const LocalStorage = {
  get: key => {
    return AsyncStorage.getItem(key).then(value => {
      return JSON.parse(value);
    });
  },

  save: (key, value) => {
    return AsyncStorage.setItem(key, JSON.stringify(value));
  },

  update: (key, value) => {
    return LocalStorage.delete(key).then(() => {
      LocalStorage.save(key, value);
    });
  },

  delete: key => {
    return AsyncStorage.removeItem(key);
  },

  reset: keys => {
    AsyncStorage.multiRemove(keys);
  }
};

export default LocalStorage;

I am on React Native version 0.60.4. I tried to manually link the library and got this error:

βœ— react-native link @react-native-community/async-storage
warn Package react-native-onesignal has been ignored because it contains invalid configuration. Reason: Unknown option dependency.platforms.ios.sourceDir with value ""./ios"" was found. This is either a typing error or a user mistake. Fixing it will remove this message.
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - appcenter-crashes: https://github.com/Microsoft/appcenter-sdk-react-native/blob/master/appcenter-crashes/README.md
  - react-native-sentry: https://github.com/getsentry/react-native-sentry
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
info Linking "@react-native-community/async-storage" iOS dependency
error Linking "@react-native-community/async-storage" failed.

I have tried closing the application and rebuilding it with this script that I use:

"clean": "watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache",

but I continue to get the same error as everyone else where it says [@RNC/AsyncStorage]:NativeModule:AsyncStorage is null

please help, I have a similar project on my Github you can try to reproduce:
https://github.com/ldco2016/NFIBEngage

My Podfile is as follows:

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

abstract_target 'defaults' do
  # Pods for NFIBEngage
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
  pod 'ReactNativeKeyboardManager', :path => '../node_modules/react-native-keyboard-manager'

  target 'NFIBEngage'
  target 'PROD'
  target 'DEV'
  target 'QA'
  target 'UA'
  target 'NFIBEngageTests'
  target 'NFIBEngage-tvOS'
  target 'NFIBEngage-tvOSTests'

end

When I try unlinking it, I get this error:

➜  NFIBEngage git:(feature/ENGA-2604) βœ— react-native unlink @react-native-community/async-storage
warn Package react-native-onesignal has been ignored because it contains invalid configuration. Reason: Unknown option dependency.platforms.ios.sourceDir with value ""./ios"" was found. This is either a typing error or a user mistake. Fixing it will remove this message.
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - appcenter-crashes: https://github.com/Microsoft/appcenter-sdk-react-native/blob/master/appcenter-crashes/README.md
  - react-native-sentry: https://github.com/getsentry/react-native-sentry
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
info iOS module "@react-native-community/async-storage" is not installed
info Android module "@react-native-community/async-storage" is not installed

How is it not installed? I have it:

βœ— npm ls @react-native-community/async-storage
[email protected] /Users/danale/Projects/NFIBEngage
└── @react-native-community/[email protected]

@jvgaeta Hey,

The Podfile looks legit. I wonder if it's because of this post_install script? Have you tried adding this one in there, to see if it'd have any effect?

Can you check, after pod install, if AsyncStorage.podspec.json is in your Pods/Local Podspecs folder?

What RN version you use?

@ldco2016

Your Podfile does not include AsyncStorage, hence the error.

If you're using RN 0.60+ you can use autolinking feature. Checkout RN's Podfile. You don't include any deps there. Leave out all React dependecies, and add use_native_modules!

@Krizzu I'm on version 0.59.

I'll give it a shot and let you know. Thanks!

The podspec json is indeed there.

{
  "name": "RNCAsyncStorage",
  "version": "1.6.1",
  "summary": "Asynchronous, persistent, key-value storage system for React Native.",
  "license": "MIT",
  "authors": {
    "name": "Krzysztof Borowy",
    "email": "[email protected]"
  },
  "homepage": "https://github.com/react-native-community/react-native-async-storage#readme",
  "platforms": {
    "ios": "9.0",
    "tvos": "9.2"
  },
  "source": {
    "git": "https://github.com/react-native-community/react-native-async-storage.git",
    "tag": "v1.6.1"
  },
  "source_files": "ios/**/*.{h,m}",
  "dependencies": {
    "React": [

    ]
  }
}

The main difference is the platform (9 here vs 10 in my others).

@jvgaeta That's interesting. Can you check what platform you're targeting in your project's settings in xcode ?

@Krizzu Deployment target is 10.0.

@jvgaeta is it possibly not included, because of the target? Can you change target to 10 in AsyncStorage's podspec in your node_modules and pod install it again?

@Krizzu ,

That Podfile you demonstrated:
https://github.com/facebook/react-native/blob/master/template/ios/Podfile

looks slightly different to mine and I don't mean because I am using abstract_target but rather because it has items configured like this:

  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'

whereas mine was generated like this:

pod 'React-Core', :path => '../node_modules/react-native/React' pod 'React-DevSupport', :path => '../node_modules/react-native/React'

I assumed that this new line which was generated for me:

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

covered anything related to @react-native-community modules

Does that mean I should go ahead and refactor my Podfile to match the pods as they are configured in the file you shared?

Also, are you suggesting I add: use_native_modules! somewhere in my Podfile?

@ldco2016 require_relative includes use_native_modules function in your Podfile, which autolinks your dependencies. So yes, you should include it in your Podfile.

Here's a diff between RN 0.59 and 0.60. I'd go ahead and copy that Podfile over, adding missing bits (you have few target statements) and try installing it.

@Krizzu ,

I am getting [!] No podspec found forReact-Corein../node_modules/react-native/`, I copied the pods over like so:

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

abstract_target 'defaults' do
  # Pods for NFIBEngage
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
  pod 'ReactNativeKeyboardManager', :path => '../node_modules/react-native-keyboard-manager'

  target 'NFIBEngage'
  target 'PROD'
  target 'DEV'
  target 'QA'
  target 'UA'
  target 'NFIBEngageTests'
  target 'NFIBEngage-tvOS'
  target 'NFIBEngage-tvOSTests'

  use_native_modules!
end

@ldco2016 This seems bit off than what diff shows. Double-check paths and module names for React pods

I'm closing this for now. Please do let me know if more help is needed (and provide info what's wrong πŸ™ )

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

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

All the best

Use import { AsyncStorage } from 'react-native'; if you are using Expo. checkout the stackoverflow https://stackoverflow.com/questions/56029007/nativemodule-asyncstorage-is-null-with-rnc-asyncstorage

This resolved for me https://react-native-community.github.io/async-storage/docs/advanced/jest/

package.json

"jest": {
  "setupFiles": ["./setup.js"]
}

setup.js

import mockAsyncStorage from '@react-native-community/async-storage/jest/async-storage-mock';

jest.mock('@react-native-community/async-storage', () => mockAsyncStorage);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rogueturnip picture rogueturnip  Β·  27Comments

alex-mironov picture alex-mironov  Β·  71Comments

mxmzb picture mxmzb  Β·  19Comments

michaelsinatra picture michaelsinatra  Β·  24Comments

muhammadn picture muhammadn  Β·  58Comments