AsyncStorage not fulfilling promise on Android 7+
I hope this problem will be solved, but issue facebook/react-native#14101 was created at 22 May 2017.
Today 15 Apr 2018
This is very quickly solution for android
Just replace
import {AsyncStorage} from 'react-native'
to
import AsyncStorage from 'rn-async-storage'
.. thats all! :)
For ios you can use all function of AsyncStorage
- setItem(key, value)
- getItem(key)
- getAllKeys()
- removeItem(key)
- clear()
- multiSet(keys[])
- multiGet(keys[])
If you need other methods from AsynStorage let me know
For ios you can use all function from AsynStorage
$ npm install rn-async-storage --save
or
$ yarn add rn-async-storage
$ react-native link rn-async-storage
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import org.gamega.RNAsyncStoragePackage;
to the imports at the top of the file - Add
new RNAsyncStoragePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':rn-async-storage' project(':rn-async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/rn-async-storage/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':rn-async-storage')