Async-storage: Undefined is not an object (evaluating 'RCTAsyncStorage.multiMerge')

Created on 15 Feb 2019  路  18Comments  路  Source: react-native-async-storage/async-storage


This issue was originally created by @boreales as facebook/react-native#22556.


Environment

React Native Environment Info:
System:
OS: macOS 10.14.1
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 463.56 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 9.5.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 26, 27
Build Tools: 27.0.3
System Images: android-27 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz => 0.57.1
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1

Description

image

Reproducible Demo

// Store/configureStore.js

import { createStore } from 'redux'
import toggleFavorite from './reducers/favoriteReducer'
import setAvatar from './reducers/avatarReducer'
import { persistCombineReducers } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const rootPersistConfig = {
  key: 'root',
  storage: storage
}

export default createStore(persistCombineReducers(rootPersistConfig, {toggleFavorite, setAvatar}))

The problem seems to be the same as #21948 but I have last react-native version and can't fix it anyway. Any idea ?

bug

Most helpful comment

In react-native 0.59 this happens only in android for me, ios runs fine.

All 18 comments

Hello,

Same issue here for me.

  1. Expo init ... Use Yarn to manage dependencies.
  2. In App.js -> componentDidMount -> Using AsyncStorage to store "foo", "bar".
  3. Before ejecting using expo, I commit so that I get a clean tree and I create index.js with RegisterComponent ...
  4. Ejecting to a Regular React Native Project... -> Ejected successfully!
  5. react-native link -> FIRST ERROR -> "Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'"
  6. yarn add @babel/runtime
  7. react-native link OK
  8. react-native run-ios (waiting ...) -> SECOND ERROR -> "Failed to install the requested application" ... "Print: Entry, ":CFBundleIdentifier", Does Not Exist"
  9. Re-run ... fingers crossed : Everything fine ! After building, the app is launched and I got "undefined is not an object (evaluating 'RCTAsyncStorage.multimerge')"

React Native Environment Info:
System:
OS: macOS 10.14.2
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Memory: 3.18 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.13.0 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5264788
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Hey @Maels1991 @boreales,

It's happening because of this code here. I'd have to dig deeper to find which native versions do not support merging, so I'd get back to you.

For now, I can suggest checking if multiMerge / mergeItem is available to avoid crashes.

In react-native 0.59 this happens only in android for me, ios runs fine.

Hi @immortalx,

Can you post repro steps? This could help us with nailing down the problem.

Hi, on react-native 0.54, this is also happening on iOS. Worked fined before ejecting. Now it's the above mentioned error.

In react-native 0.59, this happens in android even if you don't use mergeItem or multiMerge

Same is happening to me, on react-native 0.59.0

Hi @ynaveed @EduVencovsky @dimun

Regarding iOS it was a issue that slip through when we've changed names in its module, due to some problems with case-sensitive naming.

Version 1.2.1 is released, so please check if it's working for you.

Need to checkout the Android issue.

Sorry for inconvenience.

1.2.1 not working on android

@v0lume
I just initialized new project and used version 1.2.1.

Android is working fine for me.
Do you have anything that could help me track this down? Android version / device model / React Native Version used?

I had the same issue after migrating an app to 0.59.0 and importing this package instead of the one bundled with react-native core. It worked fine on iOS - no crashes and the async storage seemed to function normally (probably it used the version bundled with RN somehow) but crashed on Android with this error.

The problem was that I forgot to link the module:

./node_modules/.bin/react-native link @react-native-community/async-storage

Had this same issue on Android after upgrading to v0.59.1 (from v0.58.6).

Forgot to run react-native link @react-native-commmunity/async-storage which fixed the issue. It's not immediately apparent because (I'm assuming) there's an older version still bundled with react-native core that compiles so the compiler doesn't complain that the native module isn't found.

Thanks @tsvetan-ganev for pointing us in the right direction.

@tsvetan-ganev @JeffreyHyer Great you have this sorted.
There's Link instruction README, I think I could make it more visible.

@Krizzu sorry i could not reproduce outside my own project. Indeed i forgot to run react-native link as @JeffreyHyer said.
In my case, the link command did not add new AsyncStoragePackage() to MainApplication.java so i had to do it manually and now it's working fine in Android and IOS.

~I did run link and I'm still seeing this. I'm simply using setItem and getItem, nothing fancy.~

Deleting android/app/build and rebuilding worked for me.

Hey @EduVencovsky

Can you elaborate more on nothing works ?

@Krizzu Sorry it was my mistake, on version 1.2.2, everything is working as expected.

@EduVencovsky I see, glad you got it working.

Closing this one for now, please re-open/create new issue if this would happen again.

thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

burhanahmed92 picture burhanahmed92  路  27Comments

santhanakrishnanstark picture santhanakrishnanstark  路  67Comments

mxmzb picture mxmzb  路  19Comments

cohawk picture cohawk  路  28Comments

muhammadn picture muhammadn  路  58Comments