React-native-firebase: NativeModules.RNFirebase returns UNDEFINED

Created on 23 Jun 2017  路  20Comments  路  Source: invertase/react-native-firebase

after installation, i run the app and i get the following red screen error:
cannot read property 'googleAPIAvailability' of undefined
i tracked the issue and found that
const FirebaseModule = NativeModules.RNFirebase; IN "node_modules/react-native-firebase/lib/firebase.js" is returning "undefined"

any help please ?

My RN is v0.44

Most helpful comment

My app run is fine. But when I run "jest" (test app), the error raises. I tried to remove build folder and rerun react-native run-android, the result is still same. Can you take a look?

image

All 20 comments

You haven't installed the library properly. Please follow the instructions and if you need more help show us your build.gradle files and MainActivity.

thanks for the quick reply,

i followed the installation steps step by step,
i\m on iOS, which files would u like for me to share ?

i forgot to mention that this error happen on running:
const firebase = RNFirebase.initializeApp(configurationOptions);

I has been screen error too.

image

My RN is v.0.44 and
I followed the installation for IOS
I used it podfile this https://github.com/invertase/react-native-firebase-examples/blob/master/ios/Podfile

SOLVED .. i deleted the "build" folder in the ios (APP_ROOT_FOLDER/ios/build) and ran react-native run-ios again and all worked fine !
i guess something was not getting updated in the build folder

@barjas
I deleted the build and run-ios
but i get next error

Failed to install the requested application An application bundle was not found at the provided path. Provide a valid path to the desired application bundle. Print: Entry, ":CFBundleIdentifier", Does Not Exist

You don't get error?

@simpleblack this is not related to firebase at all
try clear cache , or run with sudo, ...or check this page, https://github.com/facebook/react-native/issues/7308

@barjas thank you.
I will try.

@barjas
I tried every method
catch clear, sudo, re make file etc...
but I get all error ":CFBundleIdentifier", Does Not Exist

my test.

  1. create react-native => success
  2. change BundleIdentifier => success || not change BundleIdentifier => success
  3. MyGame.xcworkspace indexing => success
  4. I followed the installation for IOS => fail('googleAPIAvailability' of undefined error)
  5. delete (APP_ROOT_FOLDER/ios/build/) and run-ios => fail(CFBundleIdentifier error)

I guess something pod init, pod install after get error
Could you share used podfile?

Thank you.

My app run is fine. But when I run "jest" (test app), the error raises. I tried to remove build folder and rerun react-native run-android, the result is still same. Can you take a look?

image

@Ehesp No, I don't think it's related. I've tried to add compile "com.google.android.gms:play-services-base:11.0.0" to my build.gradle, the error still appear.

@lehainam125 Okay I'll take a look. https://github.com/invertase/react-native-firebase/issues/162 might be worth checking too.

I have the same issue that @barjas had. RN 0.43.3

Tried deleting ios/build/ as well as ios/build/Build, and both result in the error that @simpleblack was having.

There seems to be no information anywhere about this "cannot read property 'googleAPIAvailability of undefined".

Also getting error 'TypeError: Cannot read property 'googleApiAvailability' of undefined' when running npm test. Error occurs on this line
const firebase = RNFirebase.initializeApp
Deleting build folder and running react-native run-android again then npm test still doesn't work.

Same issue here as @lehainam125. Works great in the app, throws this error in Jest.

Same issue I have observed

image

Getting NativeModules.RNFirebase undefined. Pretty sure I have followed all the steps suggested at here
https://github.com/evollu/react-native-fcm
Have linked library both manually and using rnpm link.
Still getting the issue

Me too,

On Android.

I use react-native-jitsi-meet library in conjuntion with this, and this problem raised.

I detailed the issue for test here Crash on Android, possible conflict with react-native-firebase plugin

When the plugin call startReactApplication to start app with jitsi view firebase plugin try to initialize RNFirebase that is not defined in that sdk.

In firebase.js, in the constructor this checks if FirebaseCoreModule (NativeModules.RNFirebase) is defined, it isn't so, fire an exception.

This initialization is not needed and causes the application crash

@RicardoBer did you find any solution for this?

I can make it work after many weeks, it's no joke, many weeks. After make a lot of changes on many code places and change xcode config, but I can't reproduce the solution.

I can build and make the app works but I can't make it again. The project is ended (lost money and time with it) and I can't make more test, Sorry.

The only conclusion I have is that it is not related to firebase problem, it is related to xcode and react native problem, but arrise on extrange sites.

Sorry, if I have more time to test and find the solution I publish it here.

Was this page helpful?
0 / 5 - 0 ratings