react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.7k stars 466 forks source link

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

Closed pulkitk702 closed 8 months ago

pulkitk702 commented 1 year ago

Proposal

To fix this issue try these steps:

• Rebuild and restart the app.

• Run the packager with --reset-cache 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://react-native-async-storage.github.io/async-storage/docs/advanced/jest I tried all these things but can't able to solve this plz provide some solution if some one knows any solution

Alternatives

No response

Implementation Details

No response

Additional Context

No response

NLanese commented 1 year ago

I have the same issue on a completely naked app. Very frustrating

krizzu commented 1 year ago

We'll need more details than that to help. Repro steps or steps that you have tried to resolve it

pulkitk702 commented 1 year ago

Actually I have found the solution:

  1. Wipe data from your Emulator or set a new device
  2. Then try to rebuild the App And by doing this it worked on me .
Anuarbekov commented 1 year ago

Close app on emulator and run "react-native run-android" or "react-native run-ios". Worked for me.

DaatKruby commented 1 year ago

I'm facing this same issue on the emulator while creating a build, but it works if I'm on development mode. I'm using expo, and eas-cli to create the build.

oliviercperrier commented 1 year ago

Facing the same issue right now.

I get this when trying running my app on a expo custom development build.

willpiam commented 1 year ago

Like @DaatKruby I'm using eas build and am getting this issue when I open my app after installing it from an APK file. I'm using version 1.19.1 of @react-native-async-storage/async-storage. I wonder if moving to an older version will help...

ahmadkarkouti commented 1 year ago

I'm having the same error on expo only when I use firebase auth.

"firebase": "^10.1.0",

Any suggestions?

willpiam commented 1 year ago

I'm currently considering alternative libraries. It's a shame because this one works very well until you need to build.

Shubhankar-1 commented 1 year ago

Hey @ahmadkarkouti I'm facing same issue. Have you found any solution for it?

willpiam commented 1 year ago

I wrote a simple replacement using expo-sqlite. It works great with redux-persist!

On Sat, Aug 12, 2023, 1:12 p.m. Shubhankar Nautiyal < @.***> wrote:

Hey @ahmadkarkouti https://github.com/ahmadkarkouti I'm facing same issue. Have you found any solution for it?

— Reply to this email directly, view it on GitHub https://github.com/react-native-async-storage/async-storage/issues/994#issuecomment-1676012130, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFVFX4IOV7OEYWBMJGRUNTTXU62RHANCNFSM6AAAAAA2R4F4SM . You are receiving this because you commented.Message ID: @.*** com>

Shubhankar-1 commented 1 year ago

@willpiam i didn't used AsyncStorage anywhere in my app it is coming from Firebase

ahmadkarkouti commented 1 year ago

My solution was to create a new expo project and add my existing files there (excluding package.json, app.json, metro.config.js, etc). Everything new except for the actual code I couldn't find how to fix the issue on my current project

tido64 commented 1 year ago

I don't know if Expo autolinks native modules the same way vanilla React Native does, but assuming it does, you need to explicitly take dependency on AsyncStorage if any of your dependencies need it. Autolinking only links native modules that are found in the current project's package.json.

Shubhankar-1 commented 1 year ago

finally this resolved my issue " npx expo install @react-native-async-storage/async-storage " 🥲.

junjielyu13 commented 1 year ago

I don't use Expo, I use RN CLI, is there any way to link manually?

{"react-native": "0.72.4",}

tido64 commented 1 year ago

I don't use Expo, I use RN CLI, is there any way to link manually?

{"react-native": "0.72.4",}

What I said here applies to RN CLI: https://github.com/react-native-async-storage/async-storage/issues/994#issuecomment-1676060963

junjielyu13 commented 1 year ago

That so weird, I didn't change anything, after recreating the project and migrated the project over, it was solved. That is really weird, but I still want to know why this happens

haddad-yacine commented 1 year ago

If you are using Expo packages in your bare React Native project, you need to update expo package to version 49 for React Native 0.72.

junjielyu13 commented 1 year ago

I ran into this issue again, but I found that the issue was that he compiled it twice on the simulator and ran two programs on the simulator at the same time. The second program would have this problem, but the first one would not. So you just need to select the home button to select the first program.

At least this is how I solved the problem. it's just a option

recallwei commented 12 months ago

I ran into this issue again, but I found that the issue was that he compiled it twice on the simulator and ran two programs on the simulator at the same time. The second program would have this problem, but the first one would not. So you just need to select the home button to select the first program.

At least this is how I solved the problem. it's just a option

Yeah, I find this, it is a temporary solution. I try to kill every app installed on the simulator before and reinstall the app, and then it works!

kimjisena commented 11 months ago

I'm currently considering alternative libraries. It's a shame because this one works very well until you need to build.

Hi

Did you find any good alternatives? I'm facing the same issue and I've tried everything to fix it but it keeps happening whenever I try to build.

Shubhankar-1 commented 11 months ago

I'm currently considering alternative libraries. It's a shame because this one works very well until you need to build.

Hi

Did you find any good alternatives? I'm facing the same issue and I've tried everything to fix it but it keeps happening whenever I try to build.

npx expo install @react-native-async-storage/async-storage

Try this

kimjisena commented 11 months ago

I'm currently considering alternative libraries. It's a shame because this one works very well until you need to build.

Hi Did you find any good alternatives? I'm facing the same issue and I've tried everything to fix it but it keeps happening whenever I try to build.

npx expo install @react-native-async-storage/async-storage

Try this

I'm using React Native CLI

saimon-moore commented 10 months ago

Using the very latest version of expo (and RN 0.72) none of these workaround fix this.

UmerHayyat54 commented 10 months ago

@tido64 i try this npx expo install @react-native-async-storage/async-storage but still facing issue

haddad-yacine commented 10 months ago

For people who use react-native-web, my problem was the babel plugin of react-native-web that I had put in the babel.config.js. Removing it solved my problem.

Remove this in babel.config.js

  [
      'react-native-web',
      {
        commonjs : true,
      },
    ]

And put it instead in the webpack configuration => webpack.config.js

github-actions[bot] commented 8 months ago

This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.