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.74k stars 467 forks source link

Async Storage is not working when I turn off debug or build app to production #271

Closed giangnguyen712 closed 4 years ago

giangnguyen712 commented 4 years ago

Current behavior

I'm getting this weird bug, cause I have try many times with my old project, Async Storage still worked ok but not in this current project. Problem is when I turn on debug for coding, the Async Storage save my data correctly. But after I turn off debug or build to production (.apk file). It didn't work anymore, data didn't setItem to save, no data return.

Expected behavior

setItem and getItem will work ok when turn off debug or build app to production.

Environment

"dependencies": { "@react-native-community/async-storage": "^1.7.1", "moment": "^2.24.0", "react": "16.8.6", "react-native": "0.61.5", "react-native-axios": "^0.17.1", "react-native-camera": "^3.8.0", "react-native-datepicker": "^1.7.2", "react-native-gesture-handler": "^1.4.1", "react-native-image-zoom-viewer": "^2.2.27", "react-native-loading-spinner-overlay": "^1.0.1", "react-native-modal-dropdown": "^0.7.0", "react-native-ratings": "^6.5.0", "react-native-reanimated": "^1.3.0", "react-native-screens": "^2.0.0-alpha.4", "react-native-sectioned-multi-select": "^0.7.6", "react-native-simple-radio-button": "^2.7.4", "react-native-snap-carousel": "3.8.0", "react-native-spinkit": "^1.5.0", "react-native-vector-icons": "^6.6.0", "react-native-webview": "^7.4.3", "react-navigation": "^4.0.10", "react-navigation-stack": "^1.9.4", "react-redux": "^7.1.1", "redux": "^4.0.1", "redux-devtools-extension": "^2.13.8", "redux-persist": "^6.0.0", "redux-thunk": "^2.3.0", "socket.io-client": "2.0.4" }, "devDependencies": { "@babel/core": "7.6.0", "@babel/runtime": "7.6.0", "babel-jest": "24.9.0", "jest": "24.9.0", "metro-react-native-babel-preset": "0.54.1", "react-native-dotenv": "^0.2.0", "react-test-renderer": "16.8.6", "redux-logger": "^3.0.6" }, "jest": { "preset": "react-native" }

giangnguyen712 commented 4 years ago

need help :(

AndreasAnderssonBluedeer commented 4 years ago

Unfortunately the same issue for me. Only on some IOS devices (so far on IOS 12.2) Only on release build.

krizzu commented 4 years ago

I think what you might be experiencing is a condition race between you using Community's AsyncStorage and your dependencies using RN Core's AsyncStorage. Try to find if any of your dependency is doing so. If that's the case, I suggest to find different dependency or use AsyncStorage from the core.

chrise86 commented 4 years ago

I'm also facing this issue. Can't see anything that's using RN Core's AS, and switching my usage to import from core does not help.

Anyone get anywhere with this?

chrise86 commented 4 years ago

@giangnguyen712 this may seem like a random question, but are you doing any date manipulation with the data you're storing? It looks like that's been my issue all along.

Here is an explanation why.

Harendra-Sharma-1998 commented 4 years ago

The same issue I stuck with, Have you @giangnguyen712 got the solution for this?

giangnguyen712 commented 4 years ago

The same issue I stuck with, Have you @giangnguyen712 got the solution for this?

The issue happen with me because I used window atob and btoa, for encode purpose, and it got bugs in react native, the weird thing is it still works when turn on debug (this is my issue: https://stackoverflow.com/questions/42829838/react-native-atob-btoa-not-working-without-remote-js-debugging). If you use RN v0.61.5 or above, try to debug by using try catch in your function, you can view the log on terminal without turn on debug, it help me find my issue.

tungduonghgg123 commented 3 years ago

@giangnguyen712 this may seem like a random question, but are you doing any date manipulation with the data you're storing? It looks like that's been my issue all along.

Here is an explanation why.

Exactly my issue, thanks!
I can store this during develoment Wed Jul 07 2021 15:29:44 GMT+0700 (Indochina Time) using moment().toDate(). However, on release mode, it does not work! I have to switch it to this form 2021-07-07T15:29:44+07:00 which is moment().format()

dozsolti commented 1 year ago

For me it was: https://github.com/react-native-async-storage/async-storage/issues/814#issuecomment-1157417097