react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Firebase doesn't work with RN 0.22.0

Open milasevicius opened this issue 10 years ago • 53 comments

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"

milasevicius avatar Mar 21 '16 17:03 milasevicius

I am getting the same error. I realise that I only get this error when I'm invoking: this.ref = new Firebase("https://somevalidapp.firebaseio.com/");

This was working at v0.21 prior to v0.22 upgrade.

holyxiaoxin avatar Mar 21 '16 17:03 holyxiaoxin

I have checked that ~v0.21 does not cause this. ^v0.22 indeed causes this.

holyxiaoxin avatar Mar 21 '16 18:03 holyxiaoxin

same here "firebase": "^2.4.1", "react": "^0.14.7", "react-native": "^0.22.0"

asubota avatar Mar 21 '16 20:03 asubota

@jwngr - any thoughts on this?

abeisgoat avatar Mar 22 '16 21:03 abeisgoat

No, but @mikelehen is probably a better person to ask.

Could either of you provide a minimal repro? Or is calling new Firebase anywhere in your code literally all you need to do make this happen?

jwngr avatar Mar 22 '16 22:03 jwngr

Commening out new Firebase works alright. Adding it back in will throw the null object reference error.

holyxiaoxin avatar Mar 22 '16 23:03 holyxiaoxin

Anybody have a stacktrace for the error handy by chance?

mikelehen avatar Mar 22 '16 23:03 mikelehen

Not sure if it's related, but this is what happens when I just import firebase into my react native project using 0.22 screen shot 2016-03-22 at 10 16 03 pm

phonghho avatar Mar 23 '16 05:03 phonghho

@mikelehen Would it be possible for you to set up CI that tests against every commit made to React Native master? That way you could ping us quickly when there's a commit that breaks the Firebase integration, and since we'd have a single commit it should be easy to fix.

Alternatively, do you test the React Native RC releases as soon as they come out?

mkonicek avatar Mar 23 '16 11:03 mkonicek

@mkonicek do you mean this?

holyxiaoxin avatar Mar 23 '16 12:03 holyxiaoxin

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.

hiradyazdan avatar Mar 23 '16 12:03 hiradyazdan

I have tested earlier versions of react-native. Surprisingly, the issue doesn't occur on 0.18 and 0.19, but since 0.20 I can repro the issue.

hiradyazdan avatar Mar 23 '16 15:03 hiradyazdan

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)

keeth avatar Mar 23 '16 18:03 keeth

@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

satya164 avatar Mar 23 '16 18:03 satya164

@facebook-github-bot answered

satya164 avatar Mar 23 '16 18:03 satya164

@satya164 yep, just filed #6611

keeth avatar Mar 23 '16 18:03 keeth

Closing this issue as @satya164 says the question asked has been answered. Please help us by asking questions on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.

facebook-github-bot avatar Mar 23 '16 18:03 facebook-github-bot

@satya164 - @keeth workaround doesn't work for me. Still broken.

justinr1234 avatar Mar 24 '16 21:03 justinr1234

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

satya164 avatar Mar 24 '16 21:03 satya164