async-storage: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null (0.61.5)

I upgraded react-native from 0.59.8 to 0.61.5 Unlinked @react-native-community/async-storage App builds successfully and splash screen comes. After that it says (In Android):

[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null
- Run react-native link @react-native-community/async-storage

When I tried linking it says:

info Linking "@react-native-community/async-storage" iOS dependency
error Linking "@react-native-community/async-storage" failed. 

If I try unlinking again (I already did before as I encountered error while upgrading), it says

info iOS module "@react-native-community/async-storage" is not installed
info Android module "@react-native-community/async-storage" is not installed

Why does it say @react-native-community/async-storage is not installed even after I installed the package? I tried removing the package and installing again. Same errors

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 25 (9 by maintainers)

Most upvoted comments

I’m facing the same problem I am using 0.61 of react-native and I’m using expo. So it should link automatically but it didn’t work, so I tried to unlink but it says that it is not installed. So I tried linking it manually and I found out that some of my android files is missing.

debug Available platforms: iOS, Android debug Package to link: @react-native-community/async-storage info Linking “@react-native-community/async-storage” Android dependency debug Patching D:\Work Files\Freelance\knoCard\android\settings.gradle error Linking “@react-native-community/async-storage” failed. Error: ENOENT: no such file or directory, open ‘D:\Work Files\Freelance\knoCard\android\settings.gradle’ at Object.openSync (fs.js:440:3) at Object.readFileSync (fs.js:342:35) at applyPatch (D:\Work Files\Freelance\knoCard\node_modules@react-native-community\cli-platform-android\build\link\patches\applyPatch.js:42:51) at Object.registerNativeAndroidModule [as register] (D:\Work Files\Freelance\knoCard\node_modules@react-native-community\cli-platform-android\build\link\registerNativeModule.js:31:27) at D:\Work Files\Freelance\knoCard\node_modules\react-native\node_modules@react-native-community\cli\build\commands\link\linkDependency.js:63:16 at Array.forEach () at linkDependency (D:\Work Files\Freelance\knoCard\node_modules\react-native\node_modules@react-native-community\cli\build\commands\link\linkDependency.js:36:32) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Object.link [as func] (D:\Work Files\Freelance\knoCard\node_modules\react-native\node_modules@react-native-community\cli\build\commands\link\link.js:107:5) at async Command.handleAction (D:\Work Files\Freelance\knoCard\node_modules\react-native\node_modules@react-native-community\cli\build\index.js:164:9)

Are you guys don’t have the same files inside your android folder except for app folder?

Now I know why I dont have android folder files, I am Using Expo and it does not support native modules like async-storage because it will look for setting.gradle or other files inside your android folder or ios folder. See https://facebook.github.io/react-native/docs/getting-started at Caveats

In other words, we need to use react-native eject or expo eject

@Krizzu Thanks, it removed the error. (But a lot of dependencies kept showing errors one after another. It’s a production app. So I created new project and migrated code to move fast)

@Krizzu I’m getting this now from a clean install.

"@react-native-community/async-storage": "^1.7.1",

I did:

  1. yarn add @react-native-community/async-storage
  2. Imported as import AsyncStorage from '@react-native-community/async-storage';
  3. Errors out straight away, followed the readme.md

@elirichey I think auto-linking does not work with custom setup from Wix navigation - you have to manually install it. So you need to add an instance of AsyncStorage’s Package to your getPackages returned array.

@hebiao6446 This what you get when you print out Promise object. You need to either await it or use .then to get the value

If you upgraded from < 0.60 version, you need to unlink all your dependencies and then relay just on cli feature. Please read the docs to get more info.

If you started with version 0.60+, then autolinking should kick in. no react-native link is required. You just need to make sure that the setup you have follows the proper setup. Again, here are the docs for autolinking.

If you’re below version 0.60, then you have to install the dependency manually or through react-native link name-of-the-library. We have guides for manual linking here

I am facing this on Android too.How to resolve this?