react-native: Firebase doesn't work with RN 0.22.0

Hello, I am getting Attempt to invoke virtual method 'java.lang.Object android.util.SparseArray.get(int)' on a null object reference. Package.json: "firebase": "^2.4.1", "react": "^0.14.7", "react-native": "^0.22.0"

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 53 (22 by maintainers)

Commits related to this issue

Most upvoted comments

This is related to babel-preset-react-native 1.5.3 enabling strict mode.

My workaround is:

echo node_modules/firebase/lib/firebase-web.js > .babelignore

(restart packager, etc)

I tried everything said in this issue and still having the same problem. It runs well on IOS but fails on Android.

rn-firebase-error

@keeth Can you create a new issue regarding a custom config not overriding the default one?

As mentioned in https://github.com/facebook/react-native/issues/6566#issuecomment-200485343 , the correct way to fix this is by adding node_modules/firebase/ to your .babelignore.

We should eventually ship a pre-built version of React Native and avoid transforming files under node_modules so that we don’t break third party code. cc @martinbigio

@mikelehen same error after creating babelignore. I am available for more test

You need to run the packager with --reset-cache after that. Otherwise it won’t work.

@satya164 yep, just filed #6611

I have exactly the same error on 0.22 like @phonghho. However, I setup a complete new project with 0.21 as well and the moment i import firebase, it throws the same error.

@gojohnnygo Worked for me, but now my SideMenu component won’t work 😢 … but that’s another issue to solve 😄 thanks for your help!

For me the error is still present in 0.23.0-rc1

This issue seems to be fixed with the version 0.23.0-rc1 👍 Thanks 😃

Thanks for the callstack @lneves12! Very helpful. It looks to me like that was a bug in react native fixed by this commit.

Can you try updating your react-native dependency to 0.23.0-rc1 which I think has the fix? Thanks!